Skip to content

Commit cfb87ff

Browse files
pinotreesaghul
authored andcommitted
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. Cherry-pick of bellard/quickjs@3489493.
1 parent aa36afe commit cfb87ff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cutils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extern "C" {
4343
#endif
4444
#if defined(__APPLE__)
4545
#include <malloc/malloc.h>
46-
#elif defined(__linux__) || defined(__ANDROID__) || defined(__CYGWIN__)
46+
#elif defined(__linux__) || defined(__ANDROID__) || defined(__CYGWIN__) || defined(__GLIBC__)
4747
#include <malloc.h>
4848
#elif defined(__FreeBSD__)
4949
#include <malloc_np.h>
@@ -586,7 +586,7 @@ static inline size_t js__malloc_usable_size(const void *ptr)
586586
return malloc_size(ptr);
587587
#elif defined(_WIN32)
588588
return _msize((void *)ptr);
589-
#elif defined(__linux__) || defined(__ANDROID__) || defined(__CYGWIN__) || defined(__FreeBSD__)
589+
#elif defined(__linux__) || defined(__ANDROID__) || defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__GLIBC__)
590590
return malloc_usable_size((void *)ptr);
591591
#else
592592
return 0;

0 commit comments

Comments
 (0)