crafting-interpreters/clox/src/memory.c

15 lines
265 B
C
Raw Normal View History

2021-07-08 11:24:24 +02:00
#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;
}