Letting hashtable_remove() return the value of the removed element is
not used anywhere in Xenstore, and it conflicts with a hashtable
created specifying the HASHTABLE_FREE_VALUE flag.
So just drop returning the value.
This of course requires to free the value if the HASHTABLE_FREE_VALUE
was specified, as otherwise it would be a memory leak.
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
}
/*****************************************************************************/
-void * /* returns value associated with key */
+void
hashtable_remove(struct hashtable *h, void *k)
{
/* TODO: consider compacting the table when the load factor drops enough,
struct entry *e;
struct entry **pE;
- void *v;
unsigned int hashvalue, index;
hashvalue = hash(h,k);
{
*pE = e->next;
h->entrycount--;
- v = e->v;
if (h->flags & HASHTABLE_FREE_KEY)
free(e->k);
+ if (h->flags & HASHTABLE_FREE_VALUE)
+ free(e->v);
free(e);
- return v;
+ return;
}
pE = &(e->next);
e = e->next;
}
- return NULL;
}
/*****************************************************************************/
* @name hashtable_remove
* @param h the hashtable to remove the item from
* @param k the key to search for - does not claim ownership
- * @return the value associated with the key, or NULL if none found
*/
-void * /* returns value */
+void
hashtable_remove(struct hashtable *h, void *k);
/*****************************************************************************