aboutsummaryrefslogtreecommitdiffstats
path: root/clox/src/memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'clox/src/memory.c')
-rw-r--r--clox/src/memory.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/clox/src/memory.c b/clox/src/memory.c
new file mode 100644
index 0000000..ead60c8
--- /dev/null
+++ b/clox/src/memory.c
@@ -0,0 +1,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;
+}