Since the method is static to remote_driver, it can't even be used by our
daemon. Other than that, it would be useful to be able to use it with admin as
well. This patch uses the new virTypedParameterRemote datatype introduced in
one of previous patches.
---
src/libvirt_private.syms | 1 +
src/remote/remote_driver.c | 23 ++++-------------------
src/util/virtypedparam.c | 29 +++++++++++++++++++++++++++++
src/util/virtypedparam.h | 3 +++
4 files changed, 37 insertions(+), 19 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index cbd71fa..5f34875 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2352,6 +2352,7 @@ virTypedParamsCopy;
virTypedParamsDeserialize;
virTypedParamsFilter;
virTypedParamsGetStringList;
+virTypedParamsRemoteFree;
virTypedParamsReplaceString;
virTypedParamsValidate;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index d712005..2702fcb 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -72,6 +72,10 @@ VIR_LOG_INIT("remote.remote_driver");
# define HYPER_TO_ULONG(_to, _from) (_to) = (_from)
#endif
+#define remoteFreeTypedParameters(remote_params_val, remote_params_len) \
+ virTypedParamsRemoteFree((virTypedParameterRemotePtr) remote_params_val, \
+ remote_params_len)
+
#define remoteDeserializeTypedParameters(remote_params_val, \
remote_params_len, \
limit, params, nparams) \
@@ -1670,25 +1674,6 @@ remoteConnectListAllDomains(virConnectPtr conn,
return rv;
}
-/* Helper to free typed parameters. */
-static void
-remoteFreeTypedParameters(remote_typed_param *args_params_val,
- u_int args_params_len)
-{
- size_t i;
-
- if (args_params_val == NULL)
- return;
-
- for (i = 0; i < args_params_len; i++) {
- VIR_FREE(args_params_val[i].field);
- if (args_params_val[i].value.type == VIR_TYPED_PARAM_STRING)
- VIR_FREE(args_params_val[i].value.remote_typed_param_value_u.s);
- }
-
- VIR_FREE(args_params_val);
-}
-
/* Helper to serialize typed parameters. */
static int
remoteSerializeTypedParameters(virTypedParameterPtr params,
diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c
index 649d032..3363147 100644
--- a/src/util/virtypedparam.c
+++ b/src/util/virtypedparam.c
@@ -1316,6 +1316,35 @@ virTypedParamsFree(virTypedParameterPtr params,
VIR_FREE(params);
}
+/**
+ * virTypedParamsRemoteFree:
+ * @remote_params_val: array of typed parameters as specified by
+ * (remote|admin)_protocol.h
+ * @remote_params_len: number of parameters in @remote_params_val
+ *
+ * Frees memory used by string representations of parameter identificators,
+ * memory used by string values of parameters and the memory occupied by
+ * @remote_params_val itself.
+ *
+ * Returns nothing.
+ */
+void
+virTypedParamsRemoteFree(virTypedParameterRemotePtr remote_params_val,
+ unsigned int remote_params_len)
+{
+ size_t i;
+
+ if (!remote_params_val)
+ return;
+
+ for (i = 0; i < remote_params_len; i++) {
+ VIR_FREE(remote_params_val[i].field);
+ if (remote_params_val[i].value.type == VIR_TYPED_PARAM_STRING)
+ VIR_FREE(remote_params_val[i].value.remote_typed_param_value.s);
+ }
+ VIR_FREE(remote_params_val);
+}
+
/**
* virTypedParamsDeserialize:
diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h
index 88b6241..72d10c2 100644
--- a/src/util/virtypedparam.h
+++ b/src/util/virtypedparam.h
@@ -104,6 +104,9 @@ int virTypedParamsCopy(virTypedParameterPtr *dst,
char *virTypedParameterToString(virTypedParameterPtr param);
+void virTypedParamsRemoteFree(virTypedParameterRemotePtr remote_params_val,
+ unsigned int remote_params_len);
+
int virTypedParamsDeserialize(const char *funcname,
virTypedParameterRemotePtr remote_params,
unsigned int remote_params_len,
--
2.4.3