crafting-interpreters/clox/src/memory.c
2021-07-08 02:25:13 -07:00

14 lines
265 B
C

#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;
}