1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

LibC: Add malloc_size() to tell you how big an allocation might be.

It can't be 100% precise but it doesn't really matter. Use this to implement
realloc() nicely. This also fixes a bug in realloc() where we didn't take
the size of the allocation metadata into account when computing the size of
an allocation backed by a BigAllocationBlock.
This commit is contained in:
Andreas Kling 2019-05-30 02:37:40 +02:00
parent a906098579
commit b160677e9e
2 changed files with 17 additions and 11 deletions

View file

@ -12,6 +12,7 @@ __BEGIN_DECLS
__attribute__((malloc)) __attribute__((alloc_size(1))) void* malloc(size_t);
__attribute__((malloc)) __attribute__((alloc_size(1, 2))) void* calloc(size_t nmemb, size_t);
size_t malloc_size(void*);
void free(void*);
void* realloc(void* ptr, size_t);
char* getenv(const char* name);