From 34894936d8ce394efa1aba7146f6cf75ad24edfe Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sun, 9 Jun 2024 09:18:38 +0200 Subject: [PATCH] Use malloc_usable_size() on any OS based on GNU libc malloc_usable_size() is a GNU extension in GNU libc; hence, use it every time GNU libc is used, rather than only on Linux. --- qjs.c | 4 ++-- quickjs.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qjs.c b/qjs.c index 0332895..7103e11 100644 --- a/qjs.c +++ b/qjs.c @@ -34,7 +34,7 @@ #include #if defined(__APPLE__) #include -#elif defined(__linux__) +#elif defined(__linux__) || defined(__GLIBC__) #include #elif defined(__FreeBSD__) #include @@ -151,7 +151,7 @@ static size_t js_trace_malloc_usable_size(const void *ptr) return _msize((void *)ptr); #elif defined(EMSCRIPTEN) return 0; -#elif defined(__linux__) +#elif defined(__linux__) || defined(__GLIBC__) return malloc_usable_size((void *)ptr); #else /* change this to `return 0;` if compilation fails */ diff --git a/quickjs.c b/quickjs.c index 3cb2643..642ae34 100644 --- a/quickjs.c +++ b/quickjs.c @@ -34,7 +34,7 @@ #include #if defined(__APPLE__) #include -#elif defined(__linux__) +#elif defined(__linux__) || defined(__GLIBC__) #include #elif defined(__FreeBSD__) #include @@ -1708,7 +1708,7 @@ static size_t js_def_malloc_usable_size(const void *ptr) return _msize((void *)ptr); #elif defined(EMSCRIPTEN) return 0; -#elif defined(__linux__) +#elif defined(__linux__) || defined(__GLIBC__) return malloc_usable_size((void *)ptr); #else /* change this to `return 0;` if compilation fails */