typedef struct {...} Bar;
const int BAR_SLOT 70;
LIST barList; // any dynamic list implementation will do here, i've once contributed one, just adapt the functions' names below
Bar* AsBar(ENTITY* e) {
if (!in(barList, e)) {
e->skill[BAR_SLOT] = (int)malloc(sizeof(Bar));
push(barList, e);
}
return (Bar*)(e->skill[BAR_SLOT]);
}
...
void cleanup(void) {
for (i = 0; i < size(barList); i ++) {
free((void*)pop(barList));
}
}