Implements code chunks, a couple of basic opcodes, constants, and basic execution of those opcodes. Signed-off-by: Daniel Henry <iamdanhenry@gmail.com>
16 lines
572 B
C
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 */
|