* virHashForEach
* @table: the hash table to process
* @iter: callback to process each element
- * @data: opaque data to pass to the iterator
+ * @opaque: opaque data to pass to the iterator
*
* Iterates over every element in the hash table, invoking the
* 'iter' callback. The callback is allowed to remove the current element
* Returns 0 on success or -1 on failure.
*/
int
-virHashForEach(virHashTablePtr table, virHashIterator iter, void *data)
+virHashForEach(virHashTablePtr table, virHashIterator iter, void *opaque)
{
size_t i;
int ret = -1;
virHashEntryPtr entry = table->table[i];
while (entry) {
virHashEntryPtr next = entry->next;
- ret = iter(entry->payload, entry->name, data);
+ ret = iter(entry->payload, entry->name, opaque);
if (ret < 0)
return ret;
* virHashRemoveSet
* @table: the hash table to process
* @iter: callback to identify elements for removal
- * @data: opaque data to pass to the iterator
+ * @opaque: opaque data to pass to the iterator
*
* Iterates over all elements in the hash table, invoking the 'iter'
* callback. If the callback returns a non-zero value, the element
ssize_t
virHashRemoveSet(virHashTablePtr table,
virHashSearcher iter,
- const void *data)
+ const void *opaque)
{
size_t i, count = 0;
while (*nextptr) {
virHashEntryPtr entry = *nextptr;
- if (!iter(entry->payload, entry->name, data)) {
+ if (!iter(entry->payload, entry->name, opaque)) {
nextptr = &entry->next;
} else {
count++;
static int
_virHashRemoveAllIter(const void *payload G_GNUC_UNUSED,
const char *name G_GNUC_UNUSED,
- const void *data G_GNUC_UNUSED)
+ const void *opaque G_GNUC_UNUSED)
{
return 1;
}
* virHashSearch:
* @table: the hash table to search
* @iter: an iterator to identify the desired element
- * @data: extra opaque information passed to the iter
+ * @opaque: extra opaque information passed to the iter
* @name: the name of found user data, pass NULL to ignore
*
* Iterates over the hash table calling the 'iter' callback
*/
void *virHashSearch(const virHashTable *ctable,
virHashSearcher iter,
- const void *data,
+ const void *opaque,
char **name)
{
size_t i;
for (i = 0; i < table->size; i++) {
virHashEntryPtr entry;
for (entry = table->table[i]; entry; entry = entry->next) {
- if (iter(entry->payload, entry->name, data)) {
+ if (iter(entry->payload, entry->name, opaque)) {
if (name)
*name = g_strdup(entry->name);
return entry->payload;
};
static int virHashEqualSearcher(const void *payload, const char *name,
- const void *data)
+ const void *opaque)
{
- struct virHashEqualData *vhed = (void *)data;
+ struct virHashEqualData *vhed = (void *)opaque;
const void *value;
value = virHashLookup(vhed->table2, name);
* virHashIterator:
* @payload: the data in the hash
* @name: the hash key
- * @data: user supplied data blob
+ * @opaque: user supplied data blob
*
* Callback to process a hash entry during iteration
*
* Returns -1 to stop the iteration, e.g. in case of an error
*/
-typedef int (*virHashIterator) (void *payload, const char *name, void *data);
+typedef int (*virHashIterator) (void *payload, const char *name, void *opaque);
/**
* virHashSearcher:
* @payload: the data in the hash
* @name: the hash key
- * @data: user supplied data blob
+ * @opaque: user supplied data blob
*
* Callback to identify hash entry desired
* Returns 1 if the hash entry is desired, 0 to move
* to next entry
*/
typedef int (*virHashSearcher) (const void *payload, const char *name,
- const void *data);
+ const void *opaque);
/*
* Constructor and destructor.
/*
* Iterators
*/
-int virHashForEach(virHashTablePtr table, virHashIterator iter, void *data);
-ssize_t virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *data);
+int virHashForEach(virHashTablePtr table, virHashIterator iter, void *opaque);
+ssize_t virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *opaque);
void *virHashSearch(const virHashTable *table, virHashSearcher iter,
- const void *data, char **name);
+ const void *opaque, char **name);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virHashTable, virHashFree);