aboutsummaryrefslogtreecommitdiffstats
path: root/clox/src/memory.c
blob: ead60c8303929dab26cd9ed6c38b447b512558af (plain)
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;
}