virHashSteal;
virHashTableSize;
virHashUpdateEntry;
+virHashValueFree;
# util/virhook.h
virClassName;
virClassNew;
virObjectFreeCallback;
+virObjectFreeHashData;
virObjectIsClass;
virObjectLock;
virObjectLockableNew;
}
-static void
-freeIfaceLock(void *payload, const void *name ATTRIBUTE_UNUSED)
-{
- VIR_FREE(payload);
-}
-
-
void
virNWFilterUnlockIface(const char *ifname)
{
return -1;
}
- ifaceLockMap = virHashCreate(0, freeIfaceLock);
+ ifaceLockMap = virHashCreate(0, virHashValueFree);
if (!ifaceLockMap) {
virNWFilterLearnShutdown();
return -1;
}
-static void
-virQEMUCapsHashDataFree(void *payload, const void *key ATTRIBUTE_UNUSED)
-{
- virObjectUnref(payload);
-}
-
-
virQEMUCapsCachePtr
virQEMUCapsCacheNew(const char *libDir,
const char *cacheDir,
return NULL;
}
- if (!(cache->binaries = virHashCreate(10, virQEMUCapsHashDataFree)))
+ if (!(cache->binaries = virHashCreate(10, virObjectFreeHashData)))
goto error;
if (VIR_STRDUP(cache->libDir, libDir) < 0)
goto error;
return 0;
}
-static void
-qemuDomainCCWAddressSetFreeEntry(void *payload,
- const void *name ATTRIBUTE_UNUSED)
-{
- VIR_FREE(payload);
-}
int qemuDomainCCWAddressAssign(virDomainDeviceInfoPtr dev,
qemuDomainCCWAddressSetPtr addrs,
if (VIR_ALLOC(addrs) < 0)
goto error;
- if (!(addrs->defined = virHashCreate(10, qemuDomainCCWAddressSetFreeEntry)))
+ if (!(addrs->defined = virHashCreate(10, virHashValueFree)))
goto error;
/* must use cssid = 0xfe (254) for virtio-ccw devices */
return NULL;
}
- if (!(table = virHashCreate(32, (virHashDataFree) free)))
+ if (!(table = virHashCreate(32, virHashValueFree)))
return NULL;
if (mon->json)
return 0;
}
-static void qemuProcessFreePtyPath(void *payload, const void *name ATTRIBUTE_UNUSED)
-{
- VIR_FREE(payload);
-}
static int
qemuProcessWaitForMonitor(virQEMUDriverPtr driver,
* reliable if it's available.
* Note that the monitor itself can be on a pty, so we still need to try the
* log output method. */
- paths = virHashCreate(0, qemuProcessFreePtyPath);
+ paths = virHashCreate(0, virHashValueFree);
if (paths == NULL)
goto cleanup;
/*
* virclosecallbacks.c: Connection close callbacks routines
*
- * Copyright (C) 2013 Red Hat, Inc.
+ * Copyright (C) 2013-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
VIR_ONCE_GLOBAL_INIT(virCloseCallbacks)
-static void
-virCloseCallbacksFreeData(void *payload,
- const void *name ATTRIBUTE_UNUSED)
-{
- VIR_FREE(payload);
-}
-
virCloseCallbacksPtr
virCloseCallbacksNew(void)
{
if (!(closeCallbacks = virObjectLockableNew(virCloseCallbacksClass)))
return NULL;
- closeCallbacks->list = virHashCreate(5, virCloseCallbacksFreeData);
+ closeCallbacks->list = virHashCreate(5, virHashValueFree);
if (!closeCallbacks->list) {
virObjectUnref(closeCallbacks);
return NULL;
*
* Reference: Your favorite introductory book on algorithms
*
- * Copyright (C) 2005-2013 Red Hat, Inc.
+ * Copyright (C) 2005-2014 Red Hat, Inc.
* Copyright (C) 2000 Bjorn Reese and Daniel Veillard.
*
* Permission to use, copy, modify, and distribute this software for any
}
+void
+virHashValueFree(void *value, const void *name ATTRIBUTE_UNUSED)
+{
+ VIR_FREE(value);
+}
+
+
static size_t
virHashComputeKey(const virHashTable *table, const void *name)
{
* Description: This module implements the hash table and allocation and
* deallocation of domains and connections
*
- * Copyright (C) 2005-2013 Red Hat, Inc.
+ * Copyright (C) 2005-2014 Red Hat, Inc.
* Copyright (C) 2000 Bjorn Reese and Daniel Veillard.
*
* Author: Bjorn Reese <bjorn.reese@systematic.dk>
void *virHashSearch(const virHashTable *table, virHashSearcher iter,
const void *data);
+/* Convenience for when VIR_FREE(value) is sufficient as a data freer. */
+void virHashValueFree(void *value, const void *name);
+
#endif /* ! __VIR_HASH_H__ */
/*
* virkeyfile.c: "ini"-style configuration file handling
*
- * Copyright (C) 2012-2013 Red Hat, Inc.
+ * Copyright (C) 2012-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
}
-static void virKeyFileValueFree(void *value, const void *name ATTRIBUTE_UNUSED)
-{
- VIR_FREE(value);
-}
-
static int virKeyFileParseGroup(virKeyFileParserCtxtPtr ctxt)
{
int ret = -1;
NEXT;
- if (!(ctxt->group = virHashCreate(10, virKeyFileValueFree)))
+ if (!(ctxt->group = virHashCreate(10, virHashValueFree)))
goto cleanup;
if (virHashAddEntry(ctxt->conf->groups, ctxt->groupname, ctxt->group) < 0)
/*
* virobject.c: libvirt reference counted object
*
- * Copyright (C) 2012-2013 Red Hat, Inc.
+ * Copyright (C) 2012-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
{
virObjectUnref(opaque);
}
+
+
+/**
+ * virObjectFreeHashData:
+ * @opaque: a pointer to a virObject instance
+ * @name: ignored, name of the hash key being deleted
+ *
+ * Provides identical functionality to virObjectUnref,
+ * but with the signature matching the virHashDataFree
+ * typedef.
+ */
+void virObjectFreeHashData(void *opaque, const void *name ATTRIBUTE_UNUSED)
+{
+ virObjectUnref(opaque);
+}
/*
* virobject.h: libvirt reference counted object
*
- * Copyright (C) 2012-2013 Red Hat, Inc.
+ * Copyright (C) 2012-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
ATTRIBUTE_NONNULL(2);
void virObjectFreeCallback(void *opaque);
+void virObjectFreeHashData(void *opaque, const void *name);
void *virObjectLockableNew(virClassPtr klass)
ATTRIBUTE_NONNULL(1);
/*
- * Copyright (C) 2011-2013 Red Hat, Inc.
+ * Copyright (C) 2011-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
if (!test)
return -1;
- if (!(blockDevices = virHashCreate(32, (virHashDataFree) free)) ||
- !(expectedBlockDevices = virHashCreate(32, (virHashDataFree) (free))))
+ if (!(blockDevices = virHashCreate(32, virHashValueFree)) ||
+ !(expectedBlockDevices = virHashCreate(32, virHashValueFree)))
goto cleanup;
if (VIR_ALLOC(info) < 0)