17 lines
389 B
C
17 lines
389 B
C
#ifndef _MEMORY_H
|
|
#define _MEMORY_H
|
|
|
|
#define GROW_CAPACITY( cap ) \
|
|
((cap) < 8 ? 8 : (cap) * 1.5f)
|
|
|
|
#define GROW_ARRAY( prev, type, oldCnt, newCnt ) \
|
|
(type*)reallocate( prev, sizeof(type) * (oldCnt), sizeof(type) * (newCnt) )
|
|
|
|
#define FREE_ARRAY( type, ptr, oldCnt ) \
|
|
reallocate( ptr, sizeof(type) * (oldCnt), 0 )
|
|
|
|
void* reallocate( void* prev, size_t oldSz, size_t newSz );
|
|
|
|
#endif
|
|
|