Added deallocation of type information to types.c. We are finally back to NOT crashing when quitting!!

This commit is contained in:
Pietro Gagliardi 2015-06-01 18:11:23 -04:00
parent a892e6b339
commit c08cad8a7e
3 changed files with 17 additions and 1 deletions

View File

@ -57,7 +57,21 @@ void *uiIsA(void *p, uintmax_t id, int fail)
return NULL;
}
// TODO free type info
void uninitTypes(void)
{
struct typeinfo *ti;
if (types == NULL) // never initialized; do nothing
return;
// the first entry is NULL; get rid of it directly
ptrArrayDelete(types, 0);
while (types->len != 0) {
ti = ptrArrayIndex(types, struct typeinfo *, 0);
ptrArrayDelete(types, 0);
uiFree(ti);
}
ptrArrayDestroy(types);
}
uiTyped *newTyped(uintmax_t type)
{

View File

@ -34,4 +34,5 @@ void ptrArrayDelete(struct ptrArray *, uintmax_t);
extern int shouldQuit(void);
// types.c
extern void uninitTypes(void);
extern uiTyped *newTyped(uintmax_t type);

View File

@ -170,6 +170,7 @@ void uiUninit(void)
// TODO delete default cursor
// TODO delete default icon
uninitResizes();
uninitTypes();
uninitAlloc();
}