Generic array in C.
Download: header file.
at : T*
size : size_t
// Declare array type.
// This defines structure and declares functions.
EARRAY_DECLARE(name, type)
// declare int array
EARRAY_DECLARE(AInt, int)
// Define array type.
// This defines functions.
EARRAY_DEFINE(name, type)
// define int space
EARRAY_DEFINE(AInt, int)
// Open with static memory.
#_open(array, at, size)
// define array and char buffer
AInt o;
char buffer[32];
// open with buffer
AInt_open(&o, buffer, 32/sizeof(int));
// print size of array
printf("%zu", o.size);
// write 0x0BADB055 at last index
o.at[o.size-1] = 0x0BADB055;
// Open with heap memory.
#_openHeap(array, size)
// open of size 64
AInt_openHeap(&o, 64);
// print size of array
printf("%zu", o.size);
// write 0x600DB055 at last index
o.at[o.size-1] = 0x600DB055;
// Close, if opened with heap memory.
#_close(array)
// close array
AInt_close(&o);
// Resize if opened with heap memory.
#_resize(array, size)
// open of size 128
AInt_openHeap(&o, 128);
// resize to size 256
AInt_resize(&o, 256);
// print size of array
printf("%zu", o.size);
// close array
AInt_close(&o);