Files
clox/include/memory.h
Daniel Henry 44c7626cd7 Finish Chapter 14
Implements code chunks, a couple of basic opcodes, constants, and
basic execution of those opcodes.

Signed-off-by: Daniel Henry <iamdanhenry@gmail.com>
2025-08-21 16:14:22 -05:00

16 lines
572 B
C

#ifndef clox_memory_h
#define clox_memory_h
#include "common.h"
#define GROW_CAPACITY(capacity) ((capacity) < 8 ? 8 : (capacity) * 2)
#define GROW_ARRAY(type, pointer, oldCount, newCount) \
(type *)reallocate(pointer, sizeof(type) * (oldCount), \
sizeof(type) * (newCount))
#define FREE_ARRAY(type, pointer, oldCount) \
reallocate(pointer, sizeof(type) * oldCount, 0);
void *reallocate(void *pointer, size_t oldSize, size_t newSize);
#endif /* clox_memory_h */