what I am trying to do is represented in my other question with code.
Basically I need to keep in memory a table of elements (structs), there's no fixed number of elements that can exist, but it is small, but I still can't use an array.
And I don't want to use a linked list of elements because I don't want to keep adding and deleting elements everytime I need to change anything.
Instead what I want to do is allocate a chunk of memory with a single malloc, that chunk of memory will be large enough for say, 100 elements, and if in the rare case that I need more, I can allocate another chunk of 100 elements and link it to the original....
Is this a good idea? is there a name for this kind of structure? it's kinda of like dynamic expanding array? Do people actually use this? or I am just on crack? if this is bad idea, what do you recommend using instead?
Thanks
typedef struct Tb{
POINT points;
POINT *next;
} TABLE;
typedef struct Pt{
int x;
int y;
}POINT;
POINT *mypoints;
int a = 10;
int b = 1000;
mypoints = (POINT*) malloc (100 * sizeof(POINT));
for (int i =0; i < 100; i++) {
mypoints->x = a++;
mypoints->y = b++;
++mypoints;
}