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>
This commit is contained in:
15
include/memory.h
Normal file
15
include/memory.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#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 */
|
||||
Reference in New Issue
Block a user