mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Reworking structures for easy testing, read more
I was reworking bits of the containers to address issue #131, then realized that the table's tests depended on a specific initial size. I'm too buggered to finish it tonight, so I'll fix it tomorrow.
This commit is contained in:
@@ -11,3 +11,22 @@ typedef struct Toy_Array { //32 | 64 BITNESS
|
||||
} Toy_Array; //8 | 8
|
||||
|
||||
TOY_API Toy_Array* Toy_resizeArray(Toy_Array* array, unsigned int capacity);
|
||||
|
||||
//some useful sizes, could be swapped out as needed
|
||||
#ifndef TOY_ARRAY_INITIAL_CAPACITY
|
||||
#define TOY_ARRAY_INITIAL_CAPACITY 8
|
||||
#endif
|
||||
|
||||
#ifndef TOY_ARRAY_EXPANSION_RATE
|
||||
#define TOY_ARRAY_EXPANSION_RATE 2
|
||||
#endif
|
||||
|
||||
//quick allocate
|
||||
#ifndef TOY_ARRAY_ALLOCATE
|
||||
#define TOY_ARRAY_ALLOCATE() Toy_resizeArray(NULL, TOY_ARRAY_INITIAL_CAPACITY)
|
||||
#endif
|
||||
|
||||
//one line to expand the array
|
||||
#ifndef TOY_ARRAY_EXPAND
|
||||
#define TOY_ARRAY_EXPAND(array) (array = (array != NULL && (array)->count + 1 > (array)->capacity ? Toy_resizeArray(array, (array)-> capacity * TOY_ARRAY_EXPANSION_RATE) : array))
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user