20 lines
444 B
C
20 lines
444 B
C
#ifndef MEMORY_INCLUDED
|
|
#define MEMORY_INCLUDED
|
|
|
|
#include "common.h"
|
|
|
|
#define GROW_CAP(cap) \
|
|
((cap ) < 8 ? 8 : (cap) * 2 )
|
|
|
|
#define GROW_ARRAY(type,pointer,oldCap,newCap) \
|
|
(type*)reallocate(pointer, sizeof(type) * (oldCap), \
|
|
sizeof(type) * (newCap))
|
|
|
|
#define FREE_ARRAY(type,pointer,oldCap) \
|
|
reallocate(pointer,sizeof(type) * (oldCap), 0)
|
|
|
|
|
|
void *reallocate(void *pointer, size_t oldCap, size_t newCap);
|
|
|
|
#endif
|