diff options
author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2005-01-19 10:31:51 +0000 |
---|---|---|
committer | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2005-01-19 10:31:51 +0000 |
commit | acd92003c8145079c6226211848e26b0472d8445 (patch) | |
tree | 56f271fbcb5b1453d93b89843daedfff749d2419 /libc/stdlib/malloc-standard/free.c | |
parent | 7b735a37585a73e8ec60a03ff52e24fe98f10cec (diff) |
Avoid compiler warnings.
Diffstat (limited to 'libc/stdlib/malloc-standard/free.c')
-rw-r--r-- | libc/stdlib/malloc-standard/free.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/libc/stdlib/malloc-standard/free.c b/libc/stdlib/malloc-standard/free.c index ec4debd56..94e1d65b1 100644 --- a/libc/stdlib/malloc-standard/free.c +++ b/libc/stdlib/malloc-standard/free.c @@ -17,37 +17,6 @@ #include "malloc.h" -/* ------------------------- malloc_trim ------------------------- - malloc_trim(size_t pad); - - If possible, gives memory back to the system (via negative - arguments to sbrk) if there is unused memory at the `high' end of - the malloc pool. You can call this after freeing large blocks of - memory to potentially reduce the system-level memory requirements - of a program. However, it cannot guarantee to reduce memory. Under - some allocation patterns, some large free blocks of memory will be - locked between two used chunks, so they cannot be given back to - the system. - - The `pad' argument to malloc_trim represents the amount of free - trailing space to leave untrimmed. If this argument is zero, - only the minimum amount of memory to maintain internal data - structures will be left (one page or less). Non-zero arguments - can be supplied to maintain enough trailing space to service - future expected allocations without having to re-obtain memory - from the system. - - Malloc_trim returns 1 if it actually released any memory, else 0. - On systems that do not support "negative sbrks", it will always - return 0. -*/ -int malloc_trim(size_t pad) -{ - mstate av = get_malloc_state(); - __malloc_consolidate(av); - return __malloc_trim(pad, av); -} - /* ------------------------- __malloc_trim ------------------------- __malloc_trim is an inverse of sorts to __malloc_alloc. It gives memory back to the system (via negative arguments to sbrk) if there is unused @@ -109,6 +78,37 @@ static int __malloc_trim(size_t pad, mstate av) return 0; } +/* ------------------------- malloc_trim ------------------------- + malloc_trim(size_t pad); + + If possible, gives memory back to the system (via negative + arguments to sbrk) if there is unused memory at the `high' end of + the malloc pool. You can call this after freeing large blocks of + memory to potentially reduce the system-level memory requirements + of a program. However, it cannot guarantee to reduce memory. Under + some allocation patterns, some large free blocks of memory will be + locked between two used chunks, so they cannot be given back to + the system. + + The `pad' argument to malloc_trim represents the amount of free + trailing space to leave untrimmed. If this argument is zero, + only the minimum amount of memory to maintain internal data + structures will be left (one page or less). Non-zero arguments + can be supplied to maintain enough trailing space to service + future expected allocations without having to re-obtain memory + from the system. + + Malloc_trim returns 1 if it actually released any memory, else 0. + On systems that do not support "negative sbrks", it will always + return 0. +*/ +int malloc_trim(size_t pad) +{ + mstate av = get_malloc_state(); + __malloc_consolidate(av); + return __malloc_trim(pad, av); +} + /* Initialize a malloc_state struct. |