From f03b81b4387ad85a071aa9f9c3966e0e3fafb23e Mon Sep 17 00:00:00 2001 From: borutr Date: Mon, 10 Mar 2003 20:07:50 +0000 Subject: [PATCH] free deleted item in function deleteSetItem() git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2366 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCset.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/SDCCset.c b/src/SDCCset.c index 3007157c..5014303f 100644 --- a/src/SDCCset.c +++ b/src/SDCCset.c @@ -203,26 +203,24 @@ deleteSetItem (set ** list, void *item) return; /* if this item is at the head of the list */ - if ((*list)->item == item) - { - lp = *list; - *list = (*list)->next; - return; - } + if ((*list)->item == item) { + lp = *list; + *list = (*list)->next; + Safe_free (lp); + return; + } /* find the item in the list */ - for (lp = *list; lp->next; lp = lp->next) - { - if (lp->next->item == item) /* the next one is it */ - { - lp1 = lp->next; /* this one will need to be freed */ - lp->next = lp->next->next; /* take out of list */ - return; - } + for (lp = *list; lp->next; lp = lp->next) { + if (lp->next->item == item) { /* the next one is it */ + lp1 = lp->next; /* this one will need to be freed */ + lp->next = lp->next->next; /* take out of list */ + Safe_free (lp1); + return; } + } /* could not find it */ - return; } /*-----------------------------------------------------------------*/ -- 2.39.5