It doesn't make much sense to configure the bucket count in the hash
table for each case specifically. Replace all calls of virHashCreate
with virHashNew which has a pre-set size and remove virHashCreate
completely.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/conf/domain_addr.c | 2 +-
src/conf/domain_conf.c | 4 ++--
src/conf/virchrdev.c | 2 +-
src/conf/virdomainmomentobjlist.c | 2 +-
src/conf/virdomainobjlist.c | 4 ++--
src/conf/virinterfaceobj.c | 2 +-
src/conf/virnetworkobj.c | 5 ++---
src/conf/virnodedeviceobj.c | 2 +-
src/conf/virnwfilterbindingobjlist.c | 2 +-
src/conf/virsecretobj.c | 2 +-
src/conf/virstorageobj.c | 10 +++++-----
src/hyperv/hyperv_wmi.c | 2 +-
src/hypervisor/virclosecallbacks.c | 2 +-
src/libvirt_private.syms | 1 -
src/libxl/libxl_logger.c | 2 +-
src/locking/lock_daemon.c | 8 ++------
src/nwfilter/nwfilter_dhcpsnoop.c | 6 +++---
src/nwfilter/nwfilter_ebiptables_driver.c | 4 ++--
src/nwfilter/nwfilter_gentech_driver.c | 2 +-
src/nwfilter/nwfilter_learnipaddr.c | 4 ++--
src/qemu/qemu_block.c | 6 +++---
src/qemu/qemu_capabilities.c | 4 ++--
src/qemu/qemu_driver.c | 2 +-
src/qemu/qemu_interop_config.c | 2 +-
src/qemu/qemu_monitor.c | 10 +++++-----
src/qemu/qemu_monitor_json.c | 2 +-
src/qemu/qemu_qapi.c | 2 +-
src/rpc/virnetdaemon.c | 2 +-
src/security/security_selinux.c | 4 ++--
src/util/virfilecache.c | 2 +-
src/util/virhash.c | 21 ---------------------
src/util/virhash.h | 2 --
src/util/viriptables.c | 4 ++--
src/util/virlockspace.c | 6 ++----
src/util/virmacmap.c | 2 +-
src/util/virstoragefile.c | 4 ++--
src/util/virsystemd.c | 2 +-
tests/qemumonitorjsontest.c | 10 +++++-----
tests/qemusecuritymock.c | 4 ++--
tests/testutilsqemu.c | 2 +-
tests/virhashtest.c | 8 ++++----
41 files changed, 69 insertions(+), 100 deletions(-)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 4e47c2547c..de344186ec 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1389,7 +1389,7 @@ virDomainCCWAddressSetCreate(void)
addrs = g_new0(virDomainCCWAddressSet, 1);
- if (!(addrs->defined = virHashCreate(10, virHashValueFree)))
+ if (!(addrs->defined = virHashNew(virHashValueFree)))
goto error;
/* must use cssid = 0xfe (254) for virtio-ccw devices */
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 37efd104f1..f4f017cf83 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5821,7 +5821,7 @@ virDomainDefBootOrderPostParse(virDomainDefPtr def)
virHashTablePtr bootHash = NULL;
int ret = -1;
- if (!(bootHash = virHashCreate(5, NULL)))
+ if (!(bootHash = virHashNew(NULL)))
goto cleanup;
if (virDomainDeviceInfoIterate(def, virDomainDefCollectBootOrder, bootHash) < 0)
@@ -6927,7 +6927,7 @@ virDomainDefValidateAliases(const virDomainDef *def,
int ret = -1;
/* We are not storing copies of aliases. Don't free them. */
- if (!(data.aliases = virHashCreate(10, NULL)))
+ if (!(data.aliases = virHashNew(NULL)))
goto cleanup;
if (virDomainDeviceInfoIterateInternal((virDomainDefPtr) def,
diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c
index c50f9ca720..0d2c9503ab 100644
--- a/src/conf/virchrdev.c
+++ b/src/conf/virchrdev.c
@@ -266,7 +266,7 @@ virChrdevsPtr virChrdevAlloc(void)
/* there will hardly be any devices most of the time, the hash
* does not have to be huge */
- if (!(devs->hash = virHashCreate(3, virChrdevHashEntryFree)))
+ if (!(devs->hash = virHashNew(virChrdevHashEntryFree)))
goto error;
return devs;
diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentobjlist.c
index 8a1eb6b734..43c77e6c54 100644
--- a/src/conf/virdomainmomentobjlist.c
+++ b/src/conf/virdomainmomentobjlist.c
@@ -275,7 +275,7 @@ virDomainMomentObjListNew(void)
virDomainMomentObjListPtr moments;
moments = g_new0(virDomainMomentObjList, 1);
- moments->objs = virHashCreate(50, virDomainMomentObjListDataFree);
+ moments->objs = virHashNew(virDomainMomentObjListDataFree);
if (!moments->objs) {
VIR_FREE(moments);
return NULL;
diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
index 46b28cc9a6..9e8757eff9 100644
--- a/src/conf/virdomainobjlist.c
+++ b/src/conf/virdomainobjlist.c
@@ -75,8 +75,8 @@ virDomainObjListPtr virDomainObjListNew(void)
if (!(doms = virObjectRWLockableNew(virDomainObjListClass)))
return NULL;
- if (!(doms->objs = virHashCreate(50, virObjectFreeHashData)) ||
- !(doms->objsName = virHashCreate(50, virObjectFreeHashData))) {
+ if (!(doms->objs = virHashNew(virObjectFreeHashData)) ||
+ !(doms->objsName = virHashNew(virObjectFreeHashData))) {
virObjectUnref(doms);
return NULL;
}
diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c
index e08b4b9b0f..1e29e12148 100644
--- a/src/conf/virinterfaceobj.c
+++ b/src/conf/virinterfaceobj.c
@@ -142,7 +142,7 @@ virInterfaceObjListNew(void)
if (!(interfaces = virObjectRWLockableNew(virInterfaceObjListClass)))
return NULL;
- if (!(interfaces->objsName = virHashCreate(10, virObjectFreeHashData))) {
+ if (!(interfaces->objsName = virHashNew(virObjectFreeHashData))) {
virObjectUnref(interfaces);
return NULL;
}
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index a2835ebf8e..3e537e512e 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -118,8 +118,7 @@ virNetworkObjNew(void)
virBitmapSetBitExpand(obj->classIdMap, 2) < 0)
goto error;
- if (!(obj->ports = virHashCreate(10,
- virNetworkObjPortFree)))
+ if (!(obj->ports = virHashNew(virNetworkObjPortFree)))
goto error;
virObjectLock(obj);
@@ -351,7 +350,7 @@ virNetworkObjListNew(void)
if (!(nets = virObjectRWLockableNew(virNetworkObjListClass)))
return NULL;
- if (!(nets->objs = virHashCreate(50, virObjectFreeHashData))) {
+ if (!(nets->objs = virHashNew(virObjectFreeHashData))) {
virObjectUnref(nets);
return NULL;
}
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index 9af80b8036..dcac4c36bb 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -454,7 +454,7 @@ virNodeDeviceObjListNew(void)
if (!(devs = virObjectRWLockableNew(virNodeDeviceObjListClass)))
return NULL;
- if (!(devs->objs = virHashCreate(50, virObjectFreeHashData))) {
+ if (!(devs->objs = virHashNew(virObjectFreeHashData))) {
virObjectUnref(devs);
return NULL;
}
diff --git a/src/conf/virnwfilterbindingobjlist.c b/src/conf/virnwfilterbindingobjlist.c
index 328b1b8482..6f4ad0bae6 100644
--- a/src/conf/virnwfilterbindingobjlist.c
+++ b/src/conf/virnwfilterbindingobjlist.c
@@ -66,7 +66,7 @@ virNWFilterBindingObjListNew(void)
if (!(bindings = virObjectRWLockableNew(virNWFilterBindingObjListClass)))
return NULL;
- if (!(bindings->objs = virHashCreate(50, virObjectFreeHashData))) {
+ if (!(bindings->objs = virHashNew(virObjectFreeHashData))) {
virObjectUnref(bindings);
return NULL;
}
diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
index d74deb9316..a3ae64ec53 100644
--- a/src/conf/virsecretobj.c
+++ b/src/conf/virsecretobj.c
@@ -119,7 +119,7 @@ virSecretObjListNew(void)
if (!(secrets = virObjectRWLockableNew(virSecretObjListClass)))
return NULL;
- if (!(secrets->objs = virHashCreate(50, virObjectFreeHashData))) {
+ if (!(secrets->objs = virHashNew(virObjectFreeHashData))) {
virObjectUnref(secrets);
return NULL;
}
diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 1c7d615a7a..1edcc3e074 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -172,9 +172,9 @@ virStorageVolObjListNew(void)
if (!(vols = virObjectRWLockableNew(virStorageVolObjListClass)))
return NULL;
- if (!(vols->objsKey = virHashCreate(10, virObjectFreeHashData)) ||
- !(vols->objsName = virHashCreate(10, virObjectFreeHashData)) ||
- !(vols->objsPath = virHashCreate(10, virObjectFreeHashData))) {
+ if (!(vols->objsKey = virHashNew(virObjectFreeHashData)) ||
+ !(vols->objsName = virHashNew(virObjectFreeHashData)) ||
+ !(vols->objsPath = virHashNew(virObjectFreeHashData))) {
virObjectUnref(vols);
return NULL;
}
@@ -404,8 +404,8 @@ virStoragePoolObjListNew(void)
if (!(pools = virObjectRWLockableNew(virStoragePoolObjListClass)))
return NULL;
- if (!(pools->objs = virHashCreate(20, virObjectFreeHashData)) ||
- !(pools->objsName = virHashCreate(20, virObjectFreeHashData))) {
+ if (!(pools->objs = virHashNew(virObjectFreeHashData)) ||
+ !(pools->objsName = virHashNew(virObjectFreeHashData))) {
virObjectUnref(pools);
return NULL;
}
diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c
index 29447b8f0f..f2fb7faeb0 100644
--- a/src/hyperv/hyperv_wmi.c
+++ b/src/hyperv/hyperv_wmi.c
@@ -332,7 +332,7 @@ hypervCreateEmbeddedParam(hypervPrivate *priv,
hypervWmiClassInfoListPtr info)
for (count = 0; typeinfo[count].name != NULL; count++)
;
- table = virHashCreate(count, NULL);
+ table = virHashNew(NULL);
if (table == NULL)
return NULL;
diff --git a/src/hypervisor/virclosecallbacks.c b/src/hypervisor/virclosecallbacks.c
index 403af047fb..176dd5c263 100644
--- a/src/hypervisor/virclosecallbacks.c
+++ b/src/hypervisor/virclosecallbacks.c
@@ -69,7 +69,7 @@ virCloseCallbacksNew(void)
if (!(closeCallbacks = virObjectLockableNew(virCloseCallbacksClass)))
return NULL;
- closeCallbacks->list = virHashCreate(5, virHashValueFree);
+ closeCallbacks->list = virHashNew(virHashValueFree);
if (!closeCallbacks->list) {
virObjectUnref(closeCallbacks);
return NULL;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 4f9e7f6048..36e2c66d93 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2199,7 +2199,6 @@ virHashAddEntry;
virHashAtomicNew;
virHashAtomicSteal;
virHashAtomicUpdate;
-virHashCreate;
virHashEqual;
virHashForEach;
virHashFree;
diff --git a/src/libxl/libxl_logger.c b/src/libxl/libxl_logger.c
index 379d7a8d00..d0ce899fe8 100644
--- a/src/libxl/libxl_logger.c
+++ b/src/libxl/libxl_logger.c
@@ -153,7 +153,7 @@ libxlLoggerNew(const char *logDir, virLogPriority minLevel)
}
logger.logDir = logDir;
- if ((logger.files = virHashCreate(3, libxlLoggerFileFree)) == NULL)
+ if ((logger.files = virHashNew(libxlLoggerFileFree)) == NULL)
return NULL;
path = g_strdup_printf("%s/libxl-driver.log", logDir);
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index 88fa7b7957..f1dabe56cd 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -56,8 +56,6 @@
VIR_LOG_INIT("locking.lock_daemon");
-#define VIR_LOCK_DAEMON_NUM_LOCKSPACES 3
-
struct _virLockDaemon {
GMutex lock;
virNetDaemonPtr dmn;
@@ -155,8 +153,7 @@ virLockDaemonNew(virLockDaemonConfigPtr config, bool privileged)
virObjectUnref(srv);
srv = NULL;
- if (!(lockd->lockspaces = virHashCreate(VIR_LOCK_DAEMON_NUM_LOCKSPACES,
- virLockDaemonLockSpaceDataFree)))
+ if (!(lockd->lockspaces = virHashNew(virLockDaemonLockSpaceDataFree)))
goto error;
if (!(lockd->defaultLockspace = virLockSpaceNew(NULL)))
@@ -215,8 +212,7 @@ virLockDaemonNewPostExecRestart(virJSONValuePtr object, bool
privileged)
g_mutex_init(&lockd->lock);
- if (!(lockd->lockspaces = virHashCreate(VIR_LOCK_DAEMON_NUM_LOCKSPACES,
- virLockDaemonLockSpaceDataFree)))
+ if (!(lockd->lockspaces = virHashNew(virLockDaemonLockSpaceDataFree)))
goto error;
if (!(child = virJSONValueObjectGet(object, "defaultLockspace"))) {
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index d0992b782c..a9cbaccdad 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -2005,10 +2005,10 @@ virNWFilterDHCPSnoopInit(void)
virMutexInit(&virNWFilterSnoopState.activeLock) < 0)
return -1;
- virNWFilterSnoopState.ifnameToKey = virHashCreate(0, NULL);
- virNWFilterSnoopState.active = virHashCreate(0, NULL);
+ virNWFilterSnoopState.ifnameToKey = virHashNew(NULL);
+ virNWFilterSnoopState.active = virHashNew(NULL);
virNWFilterSnoopState.snoopReqs =
- virHashCreate(0, virNWFilterSnoopReqRelease);
+ virHashNew(virNWFilterSnoopReqRelease);
if (!virNWFilterSnoopState.ifnameToKey ||
!virNWFilterSnoopState.snoopReqs ||
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c
b/src/nwfilter/nwfilter_ebiptables_driver.c
index e73aa82eb4..da6f88f135 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -3323,8 +3323,8 @@ ebiptablesApplyNewRules(const char *ifname,
{
size_t i, j;
g_autoptr(virFirewall) fw = virFirewallNew();
- g_autoptr(virHashTable) chains_in_set = virHashCreate(10, NULL);
- g_autoptr(virHashTable) chains_out_set = virHashCreate(10, NULL);
+ g_autoptr(virHashTable) chains_in_set = virHashNew(NULL);
+ g_autoptr(virHashTable) chains_out_set = virHashNew(NULL);
bool haveEbtables = false;
bool haveIptables = false;
bool haveIp6tables = false;
diff --git a/src/nwfilter/nwfilter_gentech_driver.c
b/src/nwfilter/nwfilter_gentech_driver.c
index 99d2c0fce4..073c91550a 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -1008,7 +1008,7 @@ virNWFilterBuildAll(virNWFilterDriverStatePtr driver,
VIR_DEBUG("Build all filters newFilters=%d", newFilters);
if (newFilters) {
- if (!(data.skipInterfaces = virHashCreate(0, NULL)))
+ if (!(data.skipInterfaces = virHashNew(NULL)))
return -1;
data.step = STEP_APPLY_NEW;
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index faf66ac84a..82797d9a64 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -777,11 +777,11 @@ virNWFilterLearnInit(void)
VIR_DEBUG("Initializing IP address learning");
threadsTerminate = false;
- pendingLearnReq = virHashCreate(0, freeLearnReqEntry);
+ pendingLearnReq = virHashNew(freeLearnReqEntry);
if (!pendingLearnReq)
return -1;
- ifaceLockMap = virHashCreate(0, virHashValueFree);
+ ifaceLockMap = virHashNew(virHashValueFree);
if (!ifaceLockMap) {
virNWFilterLearnShutdown();
return -1;
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index f1cd12a950..0c2710a7c6 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -234,7 +234,7 @@ qemuBlockNodeNameGetBackingChain(virJSONValuePtr namednodes,
memset(&data, 0, sizeof(data));
- if (!(namednodestable = virHashCreate(50, virJSONValueHashFree)))
+ if (!(namednodestable = virHashNew(virJSONValueHashFree)))
return NULL;
if (virJSONValueArrayForeachSteal(namednodes,
@@ -242,7 +242,7 @@ qemuBlockNodeNameGetBackingChain(virJSONValuePtr namednodes,
namednodestable) < 0)
return NULL;
- if (!(disks = virHashCreate(50, qemuBlockNodeNameBackingChainDataHashEntryFree)))
+ if (!(disks = virHashNew(qemuBlockNodeNameBackingChainDataHashEntryFree)))
return NULL;
data.nodenamestable = namednodestable;
@@ -370,7 +370,7 @@ qemuBlockGetNodeData(virJSONValuePtr data)
{
g_autoptr(virHashTable) nodedata = NULL;
- if (!(nodedata = virHashCreate(50, virJSONValueHashFree)))
+ if (!(nodedata = virHashNew(virJSONValueHashFree)))
return NULL;
if (virJSONValueArrayForeachSteal(data,
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 9435333a0e..2249d035fb 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1784,7 +1784,7 @@ virQEMUDomainCapsCacheNew(void)
if (!(cache = virObjectLockableNew(virQEMUDomainCapsCacheClass)))
return NULL;
- if (!(cache->cache = virHashCreate(5, virObjectFreeHashData)))
+ if (!(cache->cache = virHashNew(virObjectFreeHashData)))
return NULL;
return g_steal_pointer(&cache);
@@ -3114,7 +3114,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
qemuMonitorCPUPropertyPtr nmProp;
size_t i;
- if (!(hash = virHashCreate(0, NULL)))
+ if (!(hash = virHashNew(NULL)))
goto cleanup;
for (i = 0; i < modelInfo->nprops; i++) {
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index faf892fba3..f1191c1210 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -787,7 +787,7 @@ qemuStateInitialize(bool privileged,
if (!(qemu_driver->hostdevMgr = virHostdevManagerGetDefault()))
goto error;
- if (!(qemu_driver->sharedDevices = virHashCreate(30, qemuSharedDeviceEntryFree)))
+ if (!(qemu_driver->sharedDevices = virHashNew(qemuSharedDeviceEntryFree)))
goto error;
if (qemuMigrationDstErrorInit(qemu_driver) < 0)
diff --git a/src/qemu/qemu_interop_config.c b/src/qemu/qemu_interop_config.c
index 975cbf0afd..080674ce2d 100644
--- a/src/qemu/qemu_interop_config.c
+++ b/src/qemu/qemu_interop_config.c
@@ -125,7 +125,7 @@ qemuInteropFetchConfigs(const char *name,
homeConfig = g_strdup_printf("%s/qemu/%s", xdgConfig, name);
}
- if (!(files = virHashCreate(10, virHashValueFree)))
+ if (!(files = virHashNew(virHashValueFree)))
return -1;
if (qemuBuildFileList(files, sysLocation) < 0)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index b66d278ee5..51de72b5bf 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2086,7 +2086,7 @@ qemuMonitorGetBlockInfo(qemuMonitorPtr mon)
QEMU_CHECK_MONITOR_NULL(mon);
- if (!(table = virHashCreate(32, qemuDomainDiskInfoFree)))
+ if (!(table = virHashNew(qemuDomainDiskInfoFree)))
return NULL;
ret = qemuMonitorJSONGetBlockInfo(mon, table);
@@ -2137,7 +2137,7 @@ qemuMonitorGetAllBlockStatsInfo(qemuMonitorPtr mon,
QEMU_CHECK_MONITOR(mon);
- if (!(*ret_stats = virHashCreate(10, virHashValueFree)))
+ if (!(*ret_stats = virHashNew(virHashValueFree)))
goto error;
ret = qemuMonitorJSONGetAllBlockStatsInfo(mon, *ret_stats,
@@ -2878,7 +2878,7 @@ qemuMonitorGetChardevInfo(qemuMonitorPtr mon,
QEMU_CHECK_MONITOR_GOTO(mon, error);
- if (!(info = virHashCreate(10, qemuMonitorChardevInfoFree)))
+ if (!(info = virHashNew(qemuMonitorChardevInfoFree)))
goto error;
ret = qemuMonitorJSONGetChardevInfo(mon, info);
@@ -4289,7 +4289,7 @@ qemuMonitorGetMemoryDeviceInfo(qemuMonitorPtr mon,
QEMU_CHECK_MONITOR(mon);
- if (!(*info = virHashCreate(10, virHashValueFree)))
+ if (!(*info = virHashNew(virHashValueFree)))
return -1;
if ((ret = qemuMonitorJSONGetMemoryDeviceInfo(mon, *info)) < 0) {
@@ -4593,7 +4593,7 @@ qemuMonitorGetPRManagerInfo(qemuMonitorPtr mon,
QEMU_CHECK_MONITOR(mon);
- if (!(info = virHashCreate(10, virHashValueFree)))
+ if (!(info = virHashNew(virHashValueFree)))
goto cleanup;
if (qemuMonitorJSONGetPRManagerInfo(mon, info) < 0)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 6c763ecc12..91cc0c9046 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5126,7 +5126,7 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon,
}
nr_results = virJSONValueArraySize(data);
- if (!(blockJobs = virHashCreate(nr_results, virHashValueFree)))
+ if (!(blockJobs = virHashNew(virHashValueFree)))
goto cleanup;
for (i = 0; i < nr_results; i++) {
diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c
index 43f367f2a2..5e5fff3019 100644
--- a/src/qemu/qemu_qapi.c
+++ b/src/qemu/qemu_qapi.c
@@ -517,7 +517,7 @@ virQEMUQAPISchemaConvert(virJSONValuePtr schemareply)
g_autoptr(virHashTable) schema = NULL;
g_autoptr(virJSONValue) schemajson = schemareply;
- if (!(schema = virHashCreate(512, virJSONValueHashFree)))
+ if (!(schema = virHashNew(virJSONValueHashFree)))
return NULL;
if (virJSONValueArrayForeachSteal(schemajson,
diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
index 37a5662e04..3e2af53e82 100644
--- a/src/rpc/virnetdaemon.c
+++ b/src/rpc/virnetdaemon.c
@@ -140,7 +140,7 @@ virNetDaemonNew(void)
if (!(dmn = virObjectLockableNew(virNetDaemonClass)))
return NULL;
- if (!(dmn->servers = virHashCreate(5, virObjectFreeHashData)))
+ if (!(dmn->servers = virHashNew(virObjectFreeHashData)))
goto error;
#ifndef WIN32
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index e40d670e97..733bcf23d9 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -685,7 +685,7 @@ virSecuritySELinuxLXCInitialize(virSecurityManagerPtr mgr)
goto error;
}
- if (!(data->mcs = virHashCreate(10, NULL)))
+ if (!(data->mcs = virHashNew(NULL)))
goto error;
return 0;
@@ -757,7 +757,7 @@ virSecuritySELinuxQEMUInitialize(virSecurityManagerPtr mgr)
VIR_DEBUG("Loaded file context '%s', content context
'%s'",
data->file_context, data->content_context);
- if (!(data->mcs = virHashCreate(10, NULL)))
+ if (!(data->mcs = virHashNew(NULL)))
goto error;
return 0;
diff --git a/src/util/virfilecache.c b/src/util/virfilecache.c
index 195587e6bd..6d75e2e4fb 100644
--- a/src/util/virfilecache.c
+++ b/src/util/virfilecache.c
@@ -242,7 +242,7 @@ virFileCacheNew(const char *dir,
if (!(cache = virObjectNew(virFileCacheClass)))
return NULL;
- if (!(cache->table = virHashCreate(10, virObjectFreeHashData)))
+ if (!(cache->table = virHashNew(virObjectFreeHashData)))
goto cleanup;
cache->dir = g_strdup(dir);
diff --git a/src/util/virhash.c b/src/util/virhash.c
index 23e12e0255..ce09f8f248 100644
--- a/src/util/virhash.c
+++ b/src/util/virhash.c
@@ -190,27 +190,6 @@ virHashNew(virHashDataFree dataFree)
}
-/**
- * virHashCreate:
- * @size: the size of the hash table
- * @dataFree: callback to free data
- *
- * Create a new virHashTablePtr.
- *
- * Returns the newly created object.
- */
-virHashTablePtr virHashCreate(ssize_t size, virHashDataFree dataFree)
-{
- return virHashCreateFull(size,
- dataFree,
- virHashStrCode,
- virHashStrEqual,
- virHashStrCopy,
- virHashStrPrintHuman,
- virHashStrFree);
-}
-
-
virHashAtomicPtr
virHashAtomicNew(virHashDataFree dataFree)
{
diff --git a/src/util/virhash.h b/src/util/virhash.h
index baf92996a3..b136455f1f 100644
--- a/src/util/virhash.h
+++ b/src/util/virhash.h
@@ -112,8 +112,6 @@ typedef void (*virHashKeyFree)(void *name);
* Constructor and destructor.
*/
virHashTablePtr virHashNew(virHashDataFree dataFree);
-virHashTablePtr virHashCreate(ssize_t size,
- virHashDataFree dataFree);
virHashAtomicPtr virHashAtomicNew(virHashDataFree dataFree);
virHashTablePtr virHashCreateFull(ssize_t size,
virHashDataFree dataFree,
diff --git a/src/util/viriptables.c b/src/util/viriptables.c
index b5dd2edbd3..beab42be26 100644
--- a/src/util/viriptables.c
+++ b/src/util/viriptables.c
@@ -76,9 +76,9 @@ iptablesPrivateChainCreate(virFirewallPtr fw,
int ret = -1;
size_t i;
- if (!(chains = virHashCreate(50, NULL)))
+ if (!(chains = virHashNew(NULL)))
goto cleanup;
- if (!(links = virHashCreate(50, NULL)))
+ if (!(links = virHashNew(NULL)))
goto cleanup;
tmp = lines;
diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c
index ef370936a3..30d6a19d1d 100644
--- a/src/util/virlockspace.c
+++ b/src/util/virlockspace.c
@@ -251,8 +251,7 @@ virLockSpacePtr virLockSpaceNew(const char *directory)
lockspace->dir = g_strdup(directory);
- if (!(lockspace->resources = virHashCreate(VIR_LOCKSPACE_TABLE_SIZE,
- virLockSpaceResourceDataFree)))
+ if (!(lockspace->resources = virHashNew(virLockSpaceResourceDataFree)))
goto error;
if (directory) {
@@ -299,8 +298,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONValuePtr
object)
return NULL;
}
- if (!(lockspace->resources = virHashCreate(VIR_LOCKSPACE_TABLE_SIZE,
- virLockSpaceResourceDataFree)))
+ if (!(lockspace->resources = virHashNew(virLockSpaceResourceDataFree)))
goto error;
if (virJSONValueObjectHasKey(object, "directory")) {
diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c
index 4b5e24718d..94e73f3530 100644
--- a/src/util/virmacmap.c
+++ b/src/util/virmacmap.c
@@ -299,7 +299,7 @@ virMacMapNew(const char *file)
return NULL;
virObjectLock(mgr);
- if (!(mgr->macs = virHashCreate(VIR_MAC_HASH_TABLE_SIZE, NULL)))
+ if (!(mgr->macs = virHashNew(NULL)))
goto error;
if (file &&
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 82388ae544..33db43cd92 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -4310,7 +4310,7 @@ virStorageFileCanonicalizePath(const char *path,
beginDoubleSlash = true;
}
- if (!(cycle = virHashCreate(10, NULL)))
+ if (!(cycle = virHashNew(NULL)))
goto cleanup;
if (!(components = virStringSplitCount(path, "/", 0, &ncomponents)))
@@ -5317,7 +5317,7 @@ virStorageFileGetMetadata(virStorageSourcePtr src,
src->path, src->format, (unsigned int)uid, (unsigned int)gid,
report_broken);
- if (!(cycle = virHashCreate(5, NULL)))
+ if (!(cycle = virHashNew(NULL)))
return -1;
if (src->format <= VIR_STORAGE_FILE_NONE) {
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index 8373ee6509..09f80a1619 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -896,7 +896,7 @@ virSystemdActivationNew(virSystemdActivationMap *map,
VIR_DEBUG("Activated with %d FDs", nfds);
act = g_new0(virSystemdActivation, 1);
- if (!(act->fds = virHashCreate(10, virSystemdActivationEntryFree)))
+ if (!(act->fds = virHashNew(virSystemdActivationEntryFree)))
goto error;
fdnames = getenv("LISTEN_FDNAMES");
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 0611fdfd34..f50ecdeb3f 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1649,8 +1649,8 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockInfo(const void *opaque)
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
return -1;
- if (!(blockDevices = virHashCreate(32, virHashValueFree)) ||
- !(expectedBlockDevices = virHashCreate(32, virHashValueFree)))
+ if (!(blockDevices = virHashNew(virHashValueFree)) ||
+ !(expectedBlockDevices = virHashNew(virHashValueFree)))
goto cleanup;
info = g_new0(struct qemuDomainDiskInfo, 1);
@@ -1811,7 +1811,7 @@ testQemuMonitorJSONqemuMonitorJSONGetAllBlockStatsInfo(const void
*opaque)
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
return -1;
- if (!(blockstats = virHashCreate(10, virHashValueFree)))
+ if (!(blockstats = virHashNew(virHashValueFree)))
goto cleanup;
if (qemuMonitorTestAddItem(test, "query-blockstats", reply) < 0)
@@ -2018,8 +2018,8 @@ testQemuMonitorJSONqemuMonitorJSONGetChardevInfo(const void
*opaque)
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
return -1;
- if (!(info = virHashCreate(32, qemuMonitorChardevInfoFree)) ||
- !(expectedInfo = virHashCreate(32, NULL)))
+ if (!(info = virHashNew(qemuMonitorChardevInfoFree)) ||
+ !(expectedInfo = virHashNew(NULL)))
goto cleanup;
if (virHashAddEntry(expectedInfo, "charserial1", &info1) < 0 ||
diff --git a/tests/qemusecuritymock.c b/tests/qemusecuritymock.c
index 6366432dd4..c1344b3daa 100644
--- a/tests/qemusecuritymock.c
+++ b/tests/qemusecuritymock.c
@@ -85,12 +85,12 @@ init_hash(void)
if (xattr_paths)
return;
- if (!(xattr_paths = virHashCreate(10, virHashValueFree))) {
+ if (!(xattr_paths = virHashNew(virHashValueFree))) {
fprintf(stderr, "Unable to create hash table for XATTR paths\n");
abort();
}
- if (!(chown_paths = virHashCreate(10, virHashValueFree))) {
+ if (!(chown_paths = virHashNew(virHashValueFree))) {
fprintf(stderr, "Unable to create hash table for chowned paths\n");
abort();
}
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 5b23888a98..3f50d46d87 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -576,7 +576,7 @@ testQemuGetLatestCaps(void)
virHashTablePtr capslatest;
size_t i;
- if (!(capslatest = virHashCreate(4, virHashValueFree)))
+ if (!(capslatest = virHashNew(virHashValueFree)))
goto error;
VIR_TEST_VERBOSE("");
diff --git a/tests/virhashtest.c b/tests/virhashtest.c
index bc93c07d1f..0ba5b9ed31 100644
--- a/tests/virhashtest.c
+++ b/tests/virhashtest.c
@@ -388,7 +388,7 @@ testHashGetItems(const void *data G_GNUC_UNUSED)
char value2[] = "2";
char value3[] = "3";
- if (!(hash = virHashCreate(0, NULL)) ||
+ if (!(hash = virHashNew(NULL)) ||
virHashAddEntry(hash, keya, value3) < 0 ||
virHashAddEntry(hash, keyc, value1) < 0 ||
virHashAddEntry(hash, keyb, value2) < 0) {
@@ -458,8 +458,8 @@ testHashEqual(const void *data G_GNUC_UNUSED)
char value3_u[] = "O";
char value4_u[] = "P";
- if (!(hash1 = virHashCreate(0, NULL)) ||
- !(hash2 = virHashCreate(0, NULL)) ||
+ if (!(hash1 = virHashNew(NULL)) ||
+ !(hash2 = virHashNew(NULL)) ||
virHashAddEntry(hash1, keya, value1_l) < 0 ||
virHashAddEntry(hash1, keyb, value2_l) < 0 ||
virHashAddEntry(hash1, keyc, value3_l) < 0 ||
@@ -508,7 +508,7 @@ testHashDuplicate(const void *data G_GNUC_UNUSED)
{
g_autoptr(virHashTable) hash = NULL;
- if (!(hash = virHashCreate(0, NULL)))
+ if (!(hash = virHashNew(NULL)))
return -1;
if (virHashAddEntry(hash, "a", NULL) < 0) {
--
2.26.2