Patches for various leaks

Attached find CVS diff files to 2 source files that clean up a few memory
leaks when an app shuts down.

The first, HTIcons.c, adds the function HTIcon_deleteAll(), a function to
undo the effects of HTIconInit(). It clears out the entire icon table,
deleting all elements and nukes the table.

The second, HTMIMPrs.c, fixes the function HTParseSet_deleteAll() which had
the following problems:
	1) free'd each element twice
	2) the element tokens (pEl->token) was never being free'd
	3) the parser hash table itself (me->parsers) was never freed.

Andy Levine
andyl@infospinner.com

Index: HTIcons.c
===================================================================
RCS file: /sources/public/libwww/Library/src/HTIcons.c,v
retrieving revision 2.29
diff -r2.29 HTIcons.c
243a244,283
>
> PRIVATE void HTIconNode_delete(HTIconNode* pNode)
> {
>     HT_FREE(pNode->icon_url);
>     HT_FREE(pNode->icon_alt);
>     HT_FREE(pNode->type_templ);
>     HT_FREE(pNode);
> }
>
> /*
> **  cleans up all memory used by icons. Should be called by
> **  HTLibTerminate() (but it isn't)
> **
> */
> PUBLIC void HTIcon_deleteAll()
> {
>     if(icons != NULL)
>     {
> 	HTList * iconList = icons;
> 	HTIconNode * node;
>
> 	while((node = (HTIconNode*)HTList_removeLastObject(iconList)))
> 	{
> 	    HTIconNode_delete(node);
> 	}
>
> 	/* delete the list as well */
> 	HTList_delete(icons);
> 	icons = NULL;
>     }
>
>     HTIconNode_delete(icon_unknown);
>     icon_unknown = NULL;
>     HTIconNode_delete(icon_blank);
>     icon_blank = NULL;
>     HTIconNode_delete(icon_parent);
>     icon_parent = NULL;
>     HTIconNode_delete(icon_dir);
>     icon_dir = NULL;
> }
Index: HTMIMPrs.c
===================================================================
RCS file: /sources/public/libwww/Library/src/HTMIMPrs.c,v
retrieving revision 2.9
diff -r2.9 HTMIMPrs.c
82,87d81
<
<     for (i=0; i<me->size; i++)
< 	for (pEl = me->parsers[i]; pEl; pEl = next) {
< 	    next = pEl->next;
< 	    HT_FREE(pEl);
< 	}
89,91c83,92
<     for (pEl = me->parsers[i]; pEl; pEl = next) {
<         next = pEl->next;
< 	HT_FREE(pEl);
---
>     if(me && me->parsers) {
> 	for (i=0; i<me->size; i++) {
> 	    for (pEl = me->parsers[i]; pEl; pEl = next) {
> 		next = pEl->next;
> 		HT_FREE(pEl->token);
> 		HT_FREE(pEl);
> 	    }
> 	}
> 	HT_FREE(me->parsers);
> 	HT_FREE(me);
93d93
<     HT_FREE(me);

Received on Tuesday, 28 December 1999 11:31:01 UTC