]> git.gag.com Git - fw/sdcc/blobdiff - src/SDCChasht.c
* .version: Updated to 2.3.1
[fw/sdcc] / src / SDCChasht.c
index 69d1f2501880730b716771beddc30b3806e8f973..71821860912bff87a50720c5a815399850190a96 100644 (file)
@@ -279,6 +279,7 @@ int
 hTabDeleteByKey (hTab ** h, int key, const void *pkey, int (*compare) (const void *, const void *))
 {
   hashtItem *htip, **htipp;
+  bool found = FALSE;
 
   if (!(*h))
     return 0;
@@ -300,16 +301,22 @@ hTabDeleteByKey (hTab ** h, int key, const void *pkey, int (*compare) (const voi
           pkey == htip->pkey)
        {
          *htipp = htip->next;
+          found = TRUE;
          break;
        }
       htipp = &(htip->next);
     }
-  (*h)->nItems--;
 
-  if (!(*h)->nItems)
+  if (found == TRUE)
     {
-      *h = NULL;
+      (*h)->nItems--;
+      
+      if (!(*h)->nItems)
+        {
+          *h = NULL;
+        }
     }
+
   return 1;
 }