mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 20:00:58 +01:00
added ucrealloc()
This commit is contained in:
13
libpcp/mem.c
13
libpcp/mem.c
@@ -52,3 +52,16 @@ void *urmalloc(size_t s) {
|
||||
}
|
||||
|
||||
|
||||
void *ucrealloc(void *d, size_t oldlen, size_t newlen) {
|
||||
newlen = newlen * sizeof(unsigned char);
|
||||
void *value = realloc (d, newlen);
|
||||
|
||||
if (value == NULL) {
|
||||
err(errno, "Cannot reallocate %ld bytes of memory", newlen);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
memset (&value[oldlen], 0, newlen-oldlen);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user