提交 6241eed3 编写于 作者: S Stefan Berger 提交者: Stefan Berger

Implement virHashRemoveAll function

Implement function to remove all entries of a hash table.
上级 b83d76d4
...@@ -578,6 +578,7 @@ virHashForEach; ...@@ -578,6 +578,7 @@ virHashForEach;
virHashFree; virHashFree;
virHashGetItems; virHashGetItems;
virHashLookup; virHashLookup;
virHashRemoveAll;
virHashRemoveEntry; virHashRemoveEntry;
virHashRemoveSet; virHashRemoveSet;
virHashSearch; virHashSearch;
......
...@@ -575,6 +575,31 @@ virHashRemoveSet(virHashTablePtr table, ...@@ -575,6 +575,31 @@ virHashRemoveSet(virHashTablePtr table,
return count; 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: * virHashSearch:
* @table: the hash table to search * @table: the hash table to search
......
...@@ -126,6 +126,11 @@ int virHashUpdateEntry(virHashTablePtr table, ...@@ -126,6 +126,11 @@ int virHashUpdateEntry(virHashTablePtr table,
int virHashRemoveEntry(virHashTablePtr table, int virHashRemoveEntry(virHashTablePtr table,
const void *name); const void *name);
/*
* Remove all entries from the hash table.
*/
ssize_t virHashRemoveAll(virHashTablePtr table);
/* /*
* Retrieve the userdata. * Retrieve the userdata.
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册