util: virhash: Replace 'virHashDataFree' by 'GDestroyNotify'

We pass through to glib's hash table functions so we can also use glibs
function prototype definition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Peter Krempa 2021-11-30 14:40:43 +01:00
parent 19ddeaf607
commit 47ee68e8cc
4 changed files with 7 additions and 15 deletions

View File

@ -2830,7 +2830,7 @@ qemuMonitorJSONBlockGetNamedNodeDataJSON(virJSONValue *nodes)
{
g_autoptr(GHashTable) ret = NULL;
ret = virHashNew((virHashDataFree) qemuMonitorJSONBlockNamedNodeDataFree);
ret = virHashNew((GDestroyNotify) qemuMonitorJSONBlockNamedNodeDataFree);
if (virJSONValueArrayForeachSteal(nodes,
qemuMonitorJSONBlockGetNamedNodeDataWorker,

View File

@ -83,7 +83,7 @@ virHashTableStringKey(const void *vkey)
* Returns the newly created object.
*/
GHashTable *
virHashNew(virHashDataFree dataFree)
virHashNew(GDestroyNotify dataFree)
{
ignore_value(virHashTableSeedInitialize());
@ -92,7 +92,7 @@ virHashNew(virHashDataFree dataFree)
virHashAtomic *
virHashAtomicNew(virHashDataFree dataFree)
virHashAtomicNew(GDestroyNotify dataFree)
{
virHashAtomic *hash;

View File

@ -15,14 +15,6 @@ typedef struct _virHashAtomic virHashAtomic;
* function types:
*/
/**
* virHashDataFree:
* @payload: the data in the hash
*
* Callback to free data from a hash.
*/
typedef void (*virHashDataFree) (void *payload);
/**
* virHashIterator:
* @payload: the data in the hash
@ -50,8 +42,8 @@ typedef int (*virHashSearcher) (const void *payload, const char *name,
/*
* Constructor and destructor.
*/
GHashTable *virHashNew(virHashDataFree dataFree) G_GNUC_WARN_UNUSED_RESULT;
virHashAtomic *virHashAtomicNew(virHashDataFree dataFree);
GHashTable *virHashNew(GDestroyNotify dataFree) G_GNUC_WARN_UNUSED_RESULT;
virHashAtomic *virHashAtomicNew(GDestroyNotify dataFree);
ssize_t virHashSize(GHashTable *table);
/*

View File

@ -604,8 +604,8 @@ void virObjectFreeCallback(void *opaque)
* @name: ignored, name of the hash key being deleted
*
* Provides identical functionality to virObjectUnref,
* but with the signature matching the virHashDataFree
* typedef.
* but with the signature matching the GDestroyNotify
* typedef used with hash tables.
*/
void
virObjectFreeHashData(void *opaque)