realloc()
is not intended to re-allocate memory of stack variables (local variables of a function). This might seem trivial but is a fruitful source of accumulating memory bugs. Hence,
uint64_t* memory = NULL;
should be a heap allocation:
uint64_t *memory = (uint64_t *) malloc(sizeof(uint64_t));