We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ac536d7 commit 4b7f255Copy full SHA for 4b7f255
memory.h
@@ -0,0 +1,21 @@
1
+#ifndef MEMORY_H
2
+#define MEMORY_H
3
+
4
+#include <stddef.h>
5
6
+#define GROW_CAPACITY(capacity) \
7
+ ((capacity) < 8 ? 8 : (capacity) * 2)
8
9
+#define GROW_ARRAY(type, pointer, oldCount, newCount) \
10
+ (type*)reallocate(pointer, sizeof(type) * (oldCount), \
11
+ sizeof(type) * (newCount))
12
13
+#define FREE_ARRAY(type, pointer, oldCount) \
14
+ reallocate(pointer, sizeof(type) * (oldCount), 0)
15
16
+#define ALLOCATE(type, count) \
17
+ (type*)reallocate(NULL, 0, sizeof(type) * (count))
18
19
+#define FREE(type, pointer) reallocate(pointer, sizeof(type), 0)
20
21
+#endif
0 commit comments