hTabDeleteByKey (hTab ** h, int key, const void *pkey, int (*compare) (const void *, const void *))
{
hashtItem *htip, **htipp;
+ bool found = FALSE;
if (!(*h))
return 0;
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;
}