From 384c0131ccda2656dec23a0416ad3f14101151a7 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 3 Jun 2020 19:22:12 -0400 Subject: move oldmalloc to its own directory under src/malloc this sets the stage for replacement, and makes it practical to keep oldmalloc around as a build option for a while if that ends up being useful. only the files which are actually part of the implementation are moved. memalign and posix_memalign are entirely generic. in theory calloc could be pulled out too, but it's useful to have it tied to the implementation so as to optimize out unnecessary memset when implementation details make it possible to know the memory is already clear. --- src/malloc/oldmalloc/malloc_usable_size.c | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/malloc/oldmalloc/malloc_usable_size.c (limited to 'src/malloc/oldmalloc/malloc_usable_size.c') diff --git a/src/malloc/oldmalloc/malloc_usable_size.c b/src/malloc/oldmalloc/malloc_usable_size.c new file mode 100644 index 00000000..672b518a --- /dev/null +++ b/src/malloc/oldmalloc/malloc_usable_size.c @@ -0,0 +1,9 @@ +#include +#include "malloc_impl.h" + +hidden void *(*const __realloc_dep)(void *, size_t) = realloc; + +size_t malloc_usable_size(void *p) +{ + return p ? CHUNK_SIZE(MEM_TO_CHUNK(p)) - OVERHEAD : 0; +} -- cgit v1.2.1