Free alloc'd anims in h_dukeanim. Adds a function hash_loop().

git-svn-id: https://svn.eduke32.com/eduke32@5234 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2015-05-25 12:57:49 +00:00
parent 9814e6a091
commit 1d11b6fdd6
4 changed files with 19 additions and 1 deletions

View file

@ -1407,6 +1407,7 @@ typedef struct
} hashtable_t;
void hash_init(hashtable_t *t);
void hash_loop(hashtable_t *t, void (*func)(const char *, intptr_t));
void hash_free(hashtable_t *t);
intptr_t hash_findcase(const hashtable_t *t, const char *s);
intptr_t hash_find(const hashtable_t *t, const char *s);

View file

@ -18223,6 +18223,16 @@ void hash_init(hashtable_t *t)
t->items=(hashitem_t **)Xcalloc(1, t->size * sizeof(hashitem_t));
}
void hash_loop(hashtable_t *t, void (*func)(const char *, intptr_t))
{
if (t->items == NULL)
return;
for (int32_t i=0; i < t->size; i++)
for (hashitem_t *item=t->items[i]; item != NULL; item = item->next)
func(item->string, item->key);
}
void hash_free(hashtable_t *t)
{
if (t->items == NULL)

View file

@ -674,6 +674,7 @@ void OSD_Cleanup(void)
MAYBE_FCLOSE_AND_NULL(osdlog);
DO_FREE_AND_NULL(osd->cvars);
DO_FREE_AND_NULL(osd->editor.buf);
DO_FREE_AND_NULL(osd->editor.tmp);
for (i=0; i<OSDMAXHISTORYDEPTH; i++)
DO_FREE_AND_NULL(osd->history.buf[i]);
DO_FREE_AND_NULL(osd->text.buf);

View file

@ -10827,6 +10827,11 @@ static void G_DisplayLogo(void)
clearallviews(0L);
}
static void G_FreeHashAnim(const char *UNUSED(string), intptr_t key)
{
Bfree((void *)key);
}
static void G_Cleanup(void)
{
int32_t i;
@ -10870,7 +10875,8 @@ static void G_Cleanup(void)
hash_free(&h_gamefuncs);
#endif
hash_free(&h_dukeanim); // TODO: free the dukeanim_t structs the hash table entries point to
hash_loop(&h_dukeanim, G_FreeHashAnim);
hash_free(&h_dukeanim);
}
/*