Relax the restriction that the hash table key must be a string
by allowing an arbitrary hash code generator + comparison func
to be provided
* util/hash.c, util/hash.h: Allow any pointer as a key
* internal.h: Include stdbool.h as standard.
* conf/domain_conf.c, conf/domain_conf.c,
conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
qemu/qemu_command.c, qemu/qemu_driver.c,
qemu/qemu_process.c, uml/uml_driver.c,
xen/xm_internal.c: s/char */void */ in hash callbacks
---
src/conf/domain_conf.c | 24 ++++----
src/conf/nwfilter_params.c | 12 ++--
src/internal.h | 1 +
src/lxc/lxc_driver.c | 4 +-
src/nwfilter/nwfilter_gentech_driver.c | 2 +-
src/nwfilter/nwfilter_gentech_driver.h | 2 +-
src/nwfilter/nwfilter_learnipaddr.c | 4 +-
src/qemu/qemu_command.c | 2 +-
src/qemu/qemu_driver.c | 8 ++--
src/qemu/qemu_process.c | 4 +-
src/uml/uml_driver.c | 4 +-
src/util/hash.c | 92 +++++++++++++++++++++++---------
src/util/hash.h | 24 ++++++---
src/xen/xm_internal.c | 8 ++--
14 files changed, 122 insertions(+), 69 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b97c1f0..651e2dc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -392,7 +392,7 @@ VIR_ENUM_IMPL(virDomainTimerMode, VIR_DOMAIN_TIMER_MODE_LAST,
#define VIR_DOMAIN_XML_READ_FLAGS VIR_DOMAIN_XML_INACTIVE
static void
-virDomainObjListDeallocator(void *payload, const char *name ATTRIBUTE_UNUSED)
+virDomainObjListDeallocator(void *payload, const void *name ATTRIBUTE_UNUSED)
{
virDomainObjPtr obj = payload;
virDomainObjLock(obj);
@@ -416,7 +416,7 @@ void virDomainObjListDeinit(virDomainObjListPtr doms)
static int virDomainObjListSearchID(const void *payload,
- const char *name ATTRIBUTE_UNUSED,
+ const void *name ATTRIBUTE_UNUSED,
const void *data)
{
virDomainObjPtr obj = (virDomainObjPtr)payload;
@@ -457,7 +457,7 @@ virDomainObjPtr virDomainFindByUUID(const virDomainObjListPtr doms,
}
static int virDomainObjListSearchName(const void *payload,
- const char *name ATTRIBUTE_UNUSED,
+ const void *name ATTRIBUTE_UNUSED,
const void *data)
{
virDomainObjPtr obj = (virDomainObjPtr)payload;
@@ -8435,7 +8435,7 @@ void virDomainObjUnlock(virDomainObjPtr obj)
}
-static void virDomainObjListCountActive(void *payload, const char *name ATTRIBUTE_UNUSED,
void *data)
+static void virDomainObjListCountActive(void *payload, const void *name ATTRIBUTE_UNUSED,
void *data)
{
virDomainObjPtr obj = payload;
int *count = data;
@@ -8445,7 +8445,7 @@ static void virDomainObjListCountActive(void *payload, const char
*name ATTRIBUT
virDomainObjUnlock(obj);
}
-static void virDomainObjListCountInactive(void *payload, const char *name
ATTRIBUTE_UNUSED, void *data)
+static void virDomainObjListCountInactive(void *payload, const void *name
ATTRIBUTE_UNUSED, void *data)
{
virDomainObjPtr obj = payload;
int *count = data;
@@ -8471,7 +8471,7 @@ struct virDomainIDData {
int *ids;
};
-static void virDomainObjListCopyActiveIDs(void *payload, const char *name
ATTRIBUTE_UNUSED, void *opaque)
+static void virDomainObjListCopyActiveIDs(void *payload, const void *name
ATTRIBUTE_UNUSED, void *opaque)
{
virDomainObjPtr obj = payload;
struct virDomainIDData *data = opaque;
@@ -8497,7 +8497,7 @@ struct virDomainNameData {
char **const names;
};
-static void virDomainObjListCopyInactiveNames(void *payload, const char *name
ATTRIBUTE_UNUSED, void *opaque)
+static void virDomainObjListCopyInactiveNames(void *payload, const void *name
ATTRIBUTE_UNUSED, void *opaque)
{
virDomainObjPtr obj = payload;
struct virDomainNameData *data = opaque;
@@ -8754,7 +8754,7 @@ virDomainSnapshotObjPtr
virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr s
/* Snapshot Obj List functions */
static void
virDomainSnapshotObjListDeallocator(void *payload,
- const char *name ATTRIBUTE_UNUSED)
+ const void *name ATTRIBUTE_UNUSED)
{
virDomainSnapshotObjPtr obj = payload;
@@ -8783,7 +8783,7 @@ struct virDomainSnapshotNameData {
};
static void virDomainSnapshotObjListCopyNames(void *payload,
- const char *name ATTRIBUTE_UNUSED,
+ const void *name ATTRIBUTE_UNUSED,
void *opaque)
{
virDomainSnapshotObjPtr obj = payload;
@@ -8821,7 +8821,7 @@ cleanup:
}
static void virDomainSnapshotObjListCount(void *payload ATTRIBUTE_UNUSED,
- const char *name ATTRIBUTE_UNUSED,
+ const void *name ATTRIBUTE_UNUSED,
void *data)
{
int *count = data;
@@ -8839,7 +8839,7 @@ int virDomainSnapshotObjListNum(virDomainSnapshotObjListPtr
snapshots)
}
static int virDomainSnapshotObjListSearchName(const void *payload,
- const char *name ATTRIBUTE_UNUSED,
+ const void *name ATTRIBUTE_UNUSED,
const void *data)
{
virDomainSnapshotObjPtr obj = (virDomainSnapshotObjPtr)payload;
@@ -8870,7 +8870,7 @@ struct snapshot_has_children {
};
static void virDomainSnapshotCountChildren(void *payload,
- const char *name ATTRIBUTE_UNUSED,
+ const void *name ATTRIBUTE_UNUSED,
void *data)
{
virDomainSnapshotObjPtr obj = payload;
diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c
index cd94b30..fbd42cd 100644
--- a/src/conf/nwfilter_params.c
+++ b/src/conf/nwfilter_params.c
@@ -35,7 +35,7 @@
#define VIR_FROM_THIS VIR_FROM_NWFILTER
static void
-hashDealloc(void *payload, const char *name ATTRIBUTE_UNUSED)
+hashDealloc(void *payload, const void *name ATTRIBUTE_UNUSED)
{
VIR_FREE(payload);
}
@@ -157,7 +157,7 @@ struct addToTableStruct {
static void
-addToTable(void *payload, const char *name, void *data)
+addToTable(void *payload, const void *name, void *data)
{
struct addToTableStruct *atts = (struct addToTableStruct *)data;
char *val;
@@ -172,10 +172,10 @@ addToTable(void *payload, const char *name, void *data)
return;
}
- if (virNWFilterHashTablePut(atts->target, name, val, 1) != 0) {
+ if (virNWFilterHashTablePut(atts->target, (const char *)name, val, 1) != 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not put variable '%s' into
hashmap"),
- name);
+ (const char *)name);
atts->errOccurred = 1;
VIR_FREE(val);
}
@@ -265,13 +265,13 @@ struct formatterParam {
static void
-_formatParameterAttrs(void *payload, const char *name, void *data)
+_formatParameterAttrs(void *payload, const void *name, void *data)
{
struct formatterParam *fp = (struct formatterParam *)data;
virBufferVSprintf(fp->buf, "%s<parameter name='%s'
value='%s'/>\n",
fp->indent,
- name,
+ (const char *)name,
(char *)payload);
}
diff --git a/src/internal.h b/src/internal.h
index e263684..be97801 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -8,6 +8,7 @@
# include <errno.h>
# include <limits.h>
# include <verify.h>
+# include <stdbool.h>
# if STATIC_ANALYSIS
# undef NDEBUG /* Don't let a prior NDEBUG definition cause trouble. */
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index a17b0b6..625777a 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1968,7 +1968,7 @@ struct lxcAutostartData {
};
static void
-lxcAutostartDomain(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaque)
+lxcAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
{
virDomainObjPtr vm = payload;
const struct lxcAutostartData *data = opaque;
@@ -2015,7 +2015,7 @@ lxcAutostartConfigs(lxc_driver_t *driver) {
}
static void
-lxcReconnectVM(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaque)
+lxcReconnectVM(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
{
virDomainObjPtr vm = payload;
lxc_driver_t *driver = opaque;
diff --git a/src/nwfilter/nwfilter_gentech_driver.c
b/src/nwfilter/nwfilter_gentech_driver.c
index d81aac8..facad13 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -1012,7 +1012,7 @@ virNWFilterTeardownFilter(const virDomainNetDefPtr net)
void
virNWFilterDomainFWUpdateCB(void *payload,
- const char *name ATTRIBUTE_UNUSED,
+ const void *name ATTRIBUTE_UNUSED,
void *data)
{
virDomainObjPtr obj = payload;
diff --git a/src/nwfilter/nwfilter_gentech_driver.h
b/src/nwfilter/nwfilter_gentech_driver.h
index 271bf85..fa86030 100644
--- a/src/nwfilter/nwfilter_gentech_driver.h
+++ b/src/nwfilter/nwfilter_gentech_driver.h
@@ -64,7 +64,7 @@ virNWFilterHashTablePtr virNWFilterCreateVarHashmap(char *macaddr,
char *ipaddr);
void virNWFilterDomainFWUpdateCB(void *payload,
- const char *name ATTRIBUTE_UNUSED,
+ const void *name,
void *data);
#endif
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index 8bd7b50..0e0370a 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -189,7 +189,7 @@ virNWFilterLockIface(const char *ifname) {
static void
-freeIfaceLock(void *payload, const char *name ATTRIBUTE_UNUSED) {
+freeIfaceLock(void *payload, const void *name ATTRIBUTE_UNUSED) {
VIR_FREE(payload);
}
@@ -287,7 +287,7 @@ virNWFilterLookupLearnReq(int ifindex) {
static void
-freeLearnReqEntry(void *payload, const char *name ATTRIBUTE_UNUSED) {
+freeLearnReqEntry(void *payload, const void *name ATTRIBUTE_UNUSED) {
virNWFilterIPAddrLearnReqFree(payload);
}
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a41859c..e68a698 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -747,7 +747,7 @@ cleanup:
static void
qemuDomainPCIAddressSetFreeEntry(void *payload,
- const char *name ATTRIBUTE_UNUSED)
+ const void *name ATTRIBUTE_UNUSED)
{
VIR_FREE(payload);
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0f25a2a..fa96094 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -133,7 +133,7 @@ struct qemuAutostartData {
};
static void
-qemuAutostartDomain(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaque)
+qemuAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
{
virDomainObjPtr vm = payload;
struct qemuAutostartData *data = opaque;
@@ -273,7 +273,7 @@ err_exit:
}
static void qemuDomainSnapshotLoad(void *payload,
- const char *name ATTRIBUTE_UNUSED,
+ const void *name ATTRIBUTE_UNUSED,
void *data)
{
virDomainObjPtr vm = (virDomainObjPtr)payload;
@@ -6502,7 +6502,7 @@ struct snap_remove {
};
static void qemuDomainSnapshotDiscardChildren(void *payload,
- const char *name ATTRIBUTE_UNUSED,
+ const void *name ATTRIBUTE_UNUSED,
void *data)
{
virDomainSnapshotObjPtr snap = payload;
@@ -6533,7 +6533,7 @@ struct snap_reparent {
static void
qemuDomainSnapshotReparentChildren(void *payload,
- const char *name ATTRIBUTE_UNUSED,
+ const void *name ATTRIBUTE_UNUSED,
void *data)
{
virDomainSnapshotObjPtr snap = payload;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 9c5ea63..e418c37 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -949,7 +949,7 @@ qemuProcessFindCharDevicePTYs(virDomainObjPtr vm,
return 0;
}
-static void qemuProcessFreePtyPath(void *payload, const char *name ATTRIBUTE_UNUSED)
+static void qemuProcessFreePtyPath(void *payload, const void *name ATTRIBUTE_UNUSED)
{
VIR_FREE(payload);
}
@@ -1783,7 +1783,7 @@ struct qemuProcessReconnectData {
* and re-reserve the security labels in use
*/
static void
-qemuProcessReconnect(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaque)
+qemuProcessReconnect(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
{
virDomainObjPtr obj = payload;
struct qemuProcessReconnectData *data = opaque;
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 2af8002..7cacadb 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -149,7 +149,7 @@ struct umlAutostartData {
};
static void
-umlAutostartDomain(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaque)
+umlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
{
virDomainObjPtr vm = payload;
const struct umlAutostartData *data = opaque;
@@ -508,7 +508,7 @@ umlActive(void) {
}
static void
-umlShutdownOneVM(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaque)
+umlShutdownOneVM(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
{
virDomainObjPtr dom = payload;
struct uml_driver *driver = opaque;
diff --git a/src/util/hash.c b/src/util/hash.c
index d7950b9..aa658d4 100644
--- a/src/util/hash.c
+++ b/src/util/hash.c
@@ -43,7 +43,7 @@ typedef struct _virHashEntry virHashEntry;
typedef virHashEntry *virHashEntryPtr;
struct _virHashEntry {
struct _virHashEntry *next;
- char *name;
+ void *name;
void *payload;
int valid;
};
@@ -56,25 +56,48 @@ struct _virHashTable {
int size;
int nbElems;
virHashDeallocator f;
+ virHashCode code;
+ virHashEqual equal;
+ virHashCopy copy;
+ virHashRelease release;
};
-/*
- * virHashComputeKey:
- * Calculate the hash key
- */
-static unsigned long
-virHashComputeKey(virHashTablePtr table, const char *name)
+static unsigned long virHashStrCode(const void *name)
{
+ const char *str = name;
unsigned long value = 0L;
char ch;
- if (name != NULL) {
- value += 30 * (*name);
- while ((ch = *name++) != 0) {
+ if (str != NULL) {
+ value += 30 * (*str);
+ while ((ch = *str++) != 0) {
value =
value ^ ((value << 5) + (value >> 3) + (unsigned long) ch);
}
}
+ return value;
+}
+
+static bool virHashStrEqual(const void *namea, const void *nameb)
+{
+ return strcmp(namea, nameb) == 0 ? true : false;
+}
+
+static void *virHashStrCopy(const void *name)
+{
+ return strdup(name);
+}
+
+static void virHashStrRelease(void *name)
+{
+ VIR_FREE(name);
+}
+
+
+static unsigned long
+virHashComputeKey(virHashTablePtr table, const void *name)
+{
+ unsigned long value = table->code(name);
return (value % table->size);
}
@@ -87,8 +110,9 @@ virHashComputeKey(virHashTablePtr table, const char *name)
*
* Returns the newly created object, or NULL if an error occured.
*/
-virHashTablePtr
-virHashCreate(int size, virHashDeallocator deallocator)
+virHashTablePtr virHashCreateFull(int size, virHashDeallocator deallocator,
+ virHashCode code, virHashEqual equal,
+ virHashCopy copy, virHashRelease release)
{
virHashTablePtr table = NULL;
@@ -103,6 +127,10 @@ virHashCreate(int size, virHashDeallocator deallocator)
table->size = size;
table->nbElems = 0;
table->f = deallocator;
+ table->code = code;
+ table->equal = equal;
+ table->copy = copy;
+ table->release = release;
if (VIR_ALLOC_N(table->table, size) < 0) {
virReportOOMError();
VIR_FREE(table);
@@ -112,6 +140,17 @@ virHashCreate(int size, virHashDeallocator deallocator)
return table;
}
+virHashTablePtr
+virHashCreate(int size, virHashDeallocator deallocator)
+{
+ return virHashCreateFull(size,
+ deallocator,
+ virHashStrCode,
+ virHashStrEqual,
+ virHashStrCopy,
+ virHashStrRelease);
+}
+
/**
* virHashGrow:
* @table: the hash table
@@ -232,7 +271,8 @@ virHashFree(virHashTablePtr table)
next = iter->next;
if ((table->f != NULL) && (iter->payload != NULL))
table->f(iter->payload, iter->name);
- VIR_FREE(iter->name);
+ if (table->release)
+ table->release(iter->name);
iter->payload = NULL;
if (!inside_table)
VIR_FREE(iter);
@@ -247,7 +287,7 @@ virHashFree(virHashTablePtr table)
}
static int
-virHashAddOrUpdateEntry(virHashTablePtr table, const char *name,
+virHashAddOrUpdateEntry(virHashTablePtr table, const void *name,
void *userdata, virHashDeallocator f,
bool is_update)
{
@@ -270,13 +310,13 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const char *name,
} else {
for (insert = &(table->table[key]); insert->next != NULL;
insert = insert->next) {
- if (STREQ(insert->name, name)) {
+ if (table->equal(insert->name, name)) {
found = true;
break;
}
len++;
}
- if (STREQ(insert->name, name))
+ if (table->equal(insert->name, name))
found = true;
}
@@ -300,7 +340,7 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const char *name,
}
}
- new_name = strdup(name);
+ new_name = table->copy(name);
if (new_name == NULL) {
virReportOOMError();
if (insert != NULL)
@@ -335,7 +375,7 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const char *name,
* Returns 0 the addition succeeded and -1 in case of error.
*/
int
-virHashAddEntry(virHashTablePtr table, const char *name, void *userdata)
+virHashAddEntry(virHashTablePtr table, const void *name, void *userdata)
{
return virHashAddOrUpdateEntry(table, name, userdata, NULL, false);
}
@@ -354,7 +394,7 @@ virHashAddEntry(virHashTablePtr table, const char *name, void
*userdata)
* Returns 0 the addition succeeded and -1 in case of error.
*/
int
-virHashUpdateEntry(virHashTablePtr table, const char *name,
+virHashUpdateEntry(virHashTablePtr table, const void *name,
void *userdata, virHashDeallocator f)
{
return virHashAddOrUpdateEntry(table, name, userdata, f, true);
@@ -370,7 +410,7 @@ virHashUpdateEntry(virHashTablePtr table, const char *name,
* Returns the a pointer to the userdata
*/
void *
-virHashLookup(virHashTablePtr table, const char *name)
+virHashLookup(virHashTablePtr table, const void *name)
{
unsigned long key;
virHashEntryPtr entry;
@@ -383,7 +423,7 @@ virHashLookup(virHashTablePtr table, const char *name)
if (table->table[key].valid == 0)
return (NULL);
for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
- if (STREQ(entry->name, name))
+ if (table->equal(entry->name, name))
return (entry->payload);
}
return (NULL);
@@ -419,7 +459,7 @@ virHashSize(virHashTablePtr table)
* Returns 0 if the removal succeeded and -1 in case of error or not found.
*/
int
-virHashRemoveEntry(virHashTablePtr table, const char *name,
+virHashRemoveEntry(virHashTablePtr table, const void *name,
virHashDeallocator f)
{
unsigned long key;
@@ -435,11 +475,12 @@ virHashRemoveEntry(virHashTablePtr table, const char *name,
} else {
for (entry = &(table->table[key]); entry != NULL;
entry = entry->next) {
- if (STREQ(entry->name, name)) {
+ if (table->equal(entry->name, name)) {
if ((f != NULL) && (entry->payload != NULL))
f(entry->payload, entry->name);
entry->payload = NULL;
- VIR_FREE(entry->name);
+ if (table->release)
+ table->release(entry->name);
if (prev) {
prev->next = entry->next;
VIR_FREE(entry);
@@ -523,7 +564,8 @@ int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter,
virHashDealloc
if (iter(entry->payload, entry->name, data)) {
count++;
f(entry->payload, entry->name);
- VIR_FREE(entry->name);
+ if (table->release)
+ table->release(entry->name);
table->nbElems--;
if (prev) {
prev->next = entry->next;
diff --git a/src/util/hash.h b/src/util/hash.h
index cf08e1a..6316fd9 100644
--- a/src/util/hash.h
+++ b/src/util/hash.h
@@ -29,7 +29,7 @@ typedef virHashTable *virHashTablePtr;
*
* Callback to free data from a hash.
*/
-typedef void (*virHashDeallocator) (void *payload, const char *name);
+typedef void (*virHashDeallocator) (void *payload, const void *name);
/**
* virHashIterator:
* @payload: the data in the hash
@@ -38,7 +38,7 @@ typedef void (*virHashDeallocator) (void *payload, const char *name);
*
* Callback to process a hash entry during iteration
*/
-typedef void (*virHashIterator) (void *payload, const char *name, void *data);
+typedef void (*virHashIterator) (void *payload, const void *name, void *data);
/**
* virHashSearcher
* @payload: the data in the hash
@@ -49,13 +49,23 @@ typedef void (*virHashIterator) (void *payload, const char *name, void
*data);
* Returns 1 if the hash entry is desired, 0 to move
* to next entry
*/
-typedef int (*virHashSearcher) (const void *payload, const char *name,
+typedef int (*virHashSearcher) (const void *payload, const void *name,
const void *data);
+typedef unsigned long (*virHashCode)(const void *name);
+typedef bool (*virHashEqual)(const void *namea, const void *nameb);
+typedef void *(*virHashCopy)(const void *name);
+typedef void (*virHashRelease)(void *name);
+
/*
* Constructor and destructor.
*/
virHashTablePtr virHashCreate(int size, virHashDeallocator f);
+virHashTablePtr virHashCreateFull(int size, virHashDeallocator f,
+ virHashCode code,
+ virHashEqual equal,
+ virHashCopy copy,
+ virHashRelease release);
void virHashFree(virHashTablePtr table);
int virHashSize(virHashTablePtr table);
@@ -63,21 +73,21 @@ int virHashSize(virHashTablePtr table);
* Add a new entry to the hash table.
*/
int virHashAddEntry(virHashTablePtr table,
- const char *name, void *userdata);
+ const void *name, void *userdata);
int virHashUpdateEntry(virHashTablePtr table,
- const char *name,
+ const void *name,
void *userdata, virHashDeallocator f);
/*
* Remove an entry from the hash table.
*/
int virHashRemoveEntry(virHashTablePtr table,
- const char *name, virHashDeallocator f);
+ const void *name, virHashDeallocator f);
/*
* Retrieve the userdata.
*/
-void *virHashLookup(virHashTablePtr table, const char *name);
+void *virHashLookup(virHashTablePtr table, const void *name);
/*
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 27cc387..fe7e533 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -139,7 +139,7 @@ static int xenInotifyActive(virConnectPtr conn)
/* Release memory associated with a cached config object */
-static void xenXMConfigFree(void *payload, const char *key ATTRIBUTE_UNUSED) {
+static void xenXMConfigFree(void *payload, const void *key ATTRIBUTE_UNUSED) {
xenXMConfCachePtr entry = (xenXMConfCachePtr)payload;
virDomainDefFree(entry->def);
VIR_FREE(entry);
@@ -151,7 +151,7 @@ struct xenXMConfigReaperData {
};
/* Remove any configs which were not refreshed recently */
-static int xenXMConfigReaper(const void *payload, const char *key ATTRIBUTE_UNUSED, const
void *data) {
+static int xenXMConfigReaper(const void *payload, const void *key ATTRIBUTE_UNUSED, const
void *data) {
const struct xenXMConfigReaperData *args = data;
xenXMConfCachePtr entry = (xenXMConfCachePtr)payload;
@@ -938,7 +938,7 @@ cleanup:
/*
* Hash table iterator to search for a domain based on UUID
*/
-static int xenXMDomainSearchForUUID(const void *payload, const char *name
ATTRIBUTE_UNUSED, const void *data) {
+static int xenXMDomainSearchForUUID(const void *payload, const void *name
ATTRIBUTE_UNUSED, const void *data) {
const unsigned char *wantuuid = (const unsigned char *)data;
const xenXMConfCachePtr entry = (const xenXMConfCachePtr)payload;
@@ -1235,7 +1235,7 @@ struct xenXMListIteratorContext {
char ** names;
};
-static void xenXMListIterator(void *payload ATTRIBUTE_UNUSED, const char *name, void
*data) {
+static void xenXMListIterator(void *payload ATTRIBUTE_UNUSED, const void *name, void
*data) {
struct xenXMListIteratorContext *ctx = data;
virDomainPtr dom = NULL;
--
1.7.4