diff --git a/src/lib/safeclib.c b/src/lib/safeclib.c index 1c5cf28c6..7f8f79eb2 100644 --- a/src/lib/safeclib.c +++ b/src/lib/safeclib.c @@ -51,6 +51,17 @@ lumiera_calloc (size_t n, size_t size) } +void* +lumiera_realloc (void* ptr, size_t size) +{ + void* o = size ? realloc (ptr, size) : NULL; + if (!o) + LUMIERA_DIE (NO_MEMORY); + + return o; +} + + char* lumiera_strndup (const char* str, size_t len) { diff --git a/src/lib/safeclib.h b/src/lib/safeclib.h index 79f10d024..d949595f8 100644 --- a/src/lib/safeclib.h +++ b/src/lib/safeclib.h @@ -50,6 +50,16 @@ void* lumiera_calloc (size_t n, size_t size); +/** + * Change the size of a memory block. + * @param ptr pointer to the old memory block obtained by lumiera_malloc or lumiera_calloc + * @param size new size of the block + * @return address of new block + */ +void* +lumiera_realloc (void* ptr, size_t size); + + /** * Free previously allocated memory. * @param mem pointer to the memory block obtained by lumiera_malloc or lumiera_calloc