1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <stdlib.h> #include "memory.h" void* reallocate(void* pointer, size_t oldSize, size_t newSize) { if (newSize == 0) { free(pointer); return NULL; } void* result = realloc(pointer, newSize); if (result == NULL) exit(1); return result; }