1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 06:50:22 +03:00

Implement virHashRemoveAll function

Implement function to remove all entries of a hash table.
This commit is contained in:
Stefan Berger 2012-04-19 10:21:43 -04:00 committed by Stefan Berger
parent b83d76d40e
commit 6241eed3db
3 changed files with 31 additions and 0 deletions

View File

@ -578,6 +578,7 @@ virHashForEach;
virHashFree;
virHashGetItems;
virHashLookup;
virHashRemoveAll;
virHashRemoveEntry;
virHashRemoveSet;
virHashSearch;

View File

@ -575,6 +575,31 @@ virHashRemoveSet(virHashTablePtr table,
return count;
}
static int
_virHashRemoveAllIter(const void *payload ATTRIBUTE_UNUSED,
const void *name ATTRIBUTE_UNUSED,
const void *data ATTRIBUTE_UNUSED)
{
return 1;
}
/**
* virHashRemoveAll
* @table: the hash table to clear
*
* Free the hash @table's contents. The userdata is
* deallocated with the function provided at creation time.
*
* Returns the number of items removed on success, -1 on failure
*/
ssize_t
virHashRemoveAll(virHashTablePtr table)
{
return virHashRemoveSet(table,
_virHashRemoveAllIter,
NULL);
}
/**
* virHashSearch:
* @table: the hash table to search

View File

@ -126,6 +126,11 @@ int virHashUpdateEntry(virHashTablePtr table,
int virHashRemoveEntry(virHashTablePtr table,
const void *name);
/*
* Remove all entries from the hash table.
*/
ssize_t virHashRemoveAll(virHashTablePtr table);
/*
* Retrieve the userdata.
*/