diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-10-16 03:28:13 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-10-16 03:28:49 +0200 |
commit | cf711741c0b76a66baff916e3d781cdf6022023f (patch) | |
tree | 3772e7641cb0158e7c3571aa594b5cad929a2845 /include | |
parent | typo (diff) | |
download | slibc-cf711741c0b76a66baff916e3d781cdf6022023f.tar.gz slibc-cf711741c0b76a66baff916e3d781cdf6022023f.tar.bz2 slibc-cf711741c0b76a66baff916e3d781cdf6022023f.tar.xz |
add custom_realloc
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | include/slibc-alloc.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/slibc-alloc.h b/include/slibc-alloc.h index 3c92fcf..7bd2e81 100644 --- a/include/slibc-alloc.h +++ b/include/slibc-alloc.h @@ -109,6 +109,31 @@ void* secure_realloc(void*, size_t) __GCC_ONLY(__attribute__((warn_unused_result))); /** + * This function behaves exactly like `realloc`, + * except you can freely select what memory it clears. + * + * `crealloc(p, n)` is equivalent to (but slightly fast than) + * `custom_realloc(p, n, 1, 1, 1)`. + * + * `fast_realloc(p, n)` is equivalent to (but slightly fast than) + * `custom_realloc(p, n, 0, 0, 0)`. + * + * `secure_realloc(p, n)` is equivalent to (but slightly fast than) + * `custom_realloc(p, n, 1, 0, 1)`. + * + * @param ptr The old allocation, see `realloc` for more details. + * @param size The new allocation size, see `realloc` for more details. + * @param clear_old Whether the disowned area is cleared, even if `ptr` is returned. + * @param clear_new Whether the newly claimed area is cleared. + * @param clear_free Whether the old allocation is cleared if a new pointer is returned. + * @return The new allocation, see `realloc` for more details. + * + * @throws ENOMEM The process cannot allocate more memory. + */ +void* custom_realloc(void*, size_t, int, int, int) + __GCC_ONLY(__attribute__((warn_unused_result))); + +/** * This function behaves exactly like `fast_realloc`, except: * - Its behaviour is undefined if `ptr` is `NULL`. * - Its behaviour is undefined if `size` equals the old allocation size. |