try fix the deinit, but no luck

This commit is contained in:
Laila van Reenen 2024-04-06 14:21:49 +02:00
parent 1fee11fdba
commit 8a8348fc59

View File

@ -14,19 +14,24 @@ CMDList_t* CMDList_init()
} }
// free up the full tree from memory // free up the full tree from memory
// does not free up the commands
int CMDList_deinit(CMDList_t *list) int CMDList_deinit(CMDList_t *list)
{ {
CMDList_t* chars[26]; //TODO: cast list to array CMDList_t** list_p = (CMDList_t**)list;
// printf("deinit %p\n", (void*)list);
// printf("deinit e %p\n", list->e);
for (int i = 0; i < 26; i++) for (int i = 0; i < 26; i++)
{ {
if (chars[i] != NULL) if (*(list_p + i) != NULL)
{ {
CMDList_deinit(chars[i]); // printf("deinit %i\n", i);
CMDList_deinit(*(list_p + i));
} }
} }
free(list); //TODO: fix "free(): invalid pointer"
// free(list);
return 0; return 0;
} }