]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: virhash: Replace 'virHashDataFree' by 'GDestroyNotify'
authorPeter Krempa <pkrempa@redhat.com>
Tue, 30 Nov 2021 13:40:43 +0000 (14:40 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 1 Dec 2021 12:53:12 +0000 (13:53 +0100)
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>
src/qemu/qemu_monitor_json.c
src/util/virhash.c
src/util/virhash.h
src/util/virobject.c

index 56f0b22b2ae90c914bd74bd65ccb593214aa0963..c10ea583fd788dfe9dcd75f7f59e6fe49b82f570 100644 (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,
index ce954e86ec6ca2cc8fd2b42b324a39bda2f8f110..9fcef621fd3dc0e3f5424855d36c211357334b75 100644 (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;
 
index fcab8454bd83e75629e8b00f468f2d4febd3320c..8a6b8a7d374b2e94d5c98cfbe3aefa3977bbac2f 100644 (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);
 
 /*
index 3412985b7979c6da4ad53f09309b4988abad4877..588b41802c3dccfc18e289aa22f4f18eb55878e8 100644 (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)