Commit Graph
4 Commits
Author SHA1 Message Date
Rich Felker 239c15565f hide dependency-triggering pointer object in malloc_usable_size.c 2018-09-12 14:34:36 -04:00
Rich Felker ef8d45d6c9 rework malloc_usable_size to use malloc_impl.h 2018-09-12 14:34:36 -04:00
Szabolcs NagyandRich Felker d150764697 fix malloc_usable_size for NULL input
the linux man page specifies malloc_usable_size(0) to return 0 and
this is the semantics other implementations follow (jemalloc).
reported by Alexander Monakov.
2016-01-31 17:34:45 -05:00
Rich Felker 8d998a7b3b add malloc_usable_size function and non-stub malloc.h
this function is needed for some important practical applications of
ABI compatibility, and may be useful for supporting some non-portable
software at the source level too.

I was hesitant to add a function which imposes any constraints on
malloc internals; however, it turns out that any malloc implementation
which has realloc must already have an efficient way to determine the
size of existing allocations, so no additional constraint is imposed.

for now, some internal malloc definitions are duplicated in the new
source file. if/when malloc is refactored to put them in a shared
internal header file, these could be removed.

since malloc_usable_size is conventionally declared in malloc.h, the
empty stub version of this file was no longer suitable. it's updated
to provide the standard allocator functions, nonstandard ones (even if
stdlib.h would not expose them based on the feature test macros in
effect), and any malloc-extension functions provided (currently, only
malloc_usable_size).
2014-08-25 22:47:27 -04:00