mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
Replace all instances of 'virHashCreate' with 'virHashNew'
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@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
aa99658b06
commit
b82dfe3ba7
@ -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 */
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -2199,7 +2199,6 @@ virHashAddEntry;
|
||||
virHashAtomicNew;
|
||||
virHashAtomicSteal;
|
||||
virHashAtomicUpdate;
|
||||
virHashCreate;
|
||||
virHashEqual;
|
||||
virHashForEach;
|
||||
virHashFree;
|
||||
|
@ -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);
|
||||
|
@ -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"))) {
|
||||
|
@ -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 ||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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++) {
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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++) {
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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")) {
|
||||
|
@ -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 &&
|
||||
|
@ -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) {
|
||||
|
@ -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");
|
||||
|
@ -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 ||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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("");
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user