Add an allocator function and refactor all allocations to use it. In upcoming patches 'struct _virTypedParamList' will be made private. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/admin/admin_server.c | 6 +++--- src/libvirt_private.syms | 1 + src/qemu/qemu_domainjob.c | 2 +- src/qemu/qemu_driver.c | 2 +- src/test/test_driver.c | 2 +- src/util/virtypedparam.c | 9 ++++++++- src/util/virtypedparam.h | 1 + 7 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/admin/admin_server.c b/src/admin/admin_server.c index 7ed2645f57..394de0dfab 100644 --- a/src/admin/admin_server.c +++ b/src/admin/admin_server.c @@ -76,7 +76,7 @@ adminServerGetThreadPoolParameters(virNetServer *srv, size_t freeWorkers; size_t nPrioWorkers; size_t jobQueueDepth; - g_autoptr(virTypedParamList) paramlist = g_new0(virTypedParamList, 1); + g_autoptr(virTypedParamList) paramlist = virTypedParamListNew(); virCheckFlags(0, -1); @@ -200,7 +200,7 @@ adminClientGetInfo(virNetServerClient *client, bool readonly; g_autofree char *sock_addr = NULL; const char *attr = NULL; - g_autoptr(virTypedParamList) paramlist = g_new0(virTypedParamList, 1); + g_autoptr(virTypedParamList) paramlist = virTypedParamListNew(); g_autoptr(virIdentity) identity = NULL; int rc; @@ -298,7 +298,7 @@ adminServerGetClientLimits(virNetServer *srv, int *nparams, unsigned int flags) { - g_autoptr(virTypedParamList) paramlist = g_new0(virTypedParamList, 1); + g_autoptr(virTypedParamList) paramlist = virTypedParamListNew(); virCheckFlags(0, -1); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1247b67a39..c596ef0f87 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3557,6 +3557,7 @@ virTypedParamListAddUInt; virTypedParamListAddULLong; virTypedParamListFree; virTypedParamListFromParams; +virTypedParamListNew; virTypedParamListStealParams; virTypedParamsCheck; virTypedParamsCopy; diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index 6376f928d5..4df1af0ce7 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -478,7 +478,7 @@ qemuDomainBackupJobDataToParams(virDomainJobData *jobData, { qemuDomainJobDataPrivate *priv = jobData->privateData; qemuDomainBackupStats *stats = &priv->stats.backup; - g_autoptr(virTypedParamList) par = g_new0(virTypedParamList, 1); + g_autoptr(virTypedParamList) par = virTypedParamListNew(); if (virTypedParamListAddInt(par, jobData->operation, VIR_DOMAIN_JOB_OPERATION) < 0) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 28e470e4a2..4cf5e8a512 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18447,7 +18447,7 @@ qemuDomainGetStats(virConnectPtr conn, g_autoptr(virTypedParamList) params = NULL; size_t i; - params = g_new0(virTypedParamList, 1); + params = virTypedParamListNew(); for (i = 0; qemuDomainGetStatsWorkers[i].func; i++) { if (stats & qemuDomainGetStatsWorkers[i].stats) { diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 7b06896d44..47c74c420c 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9858,7 +9858,7 @@ testDomainGetStats(virConnectPtr conn, g_autoptr(virTypedParamList) params = NULL; size_t i; - params = g_new0(virTypedParamList, 1); + params = virTypedParamListNew(); for (i = 0; testDomainGetStatsWorkers[i].func; i++) { if (stats & testDomainGetStatsWorkers[i].stats) { diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 1a1a34fdb2..de3a4e76b4 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -705,6 +705,13 @@ virTypedParamsSerialize(virTypedParameterPtr params, } +virTypedParamList * +virTypedParamListNew(void) +{ + return g_new0(virTypedParamList, 1); +} + + void virTypedParamListFree(virTypedParamList *list) { @@ -733,7 +740,7 @@ virTypedParamList * virTypedParamListFromParams(virTypedParameterPtr *params, size_t nparams) { - virTypedParamList *l = g_new0(virTypedParamList, 1); + virTypedParamList *l = virTypedParamListNew(); l->par = g_steal_pointer(params); l->npar = nparams; diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index fb9815c661..4aa597bc81 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -146,6 +146,7 @@ struct _virTypedParamList { void virTypedParamListFree(virTypedParamList *list); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virTypedParamList, virTypedParamListFree); +virTypedParamList *virTypedParamListNew(void); size_t virTypedParamListStealParams(virTypedParamList *list, -- 2.39.2