]> xenbits.xensource.com Git - libvirt.git/commit
util: typedparam: Simplify handling of lists of typed parameters
authorPeter Krempa <pkrempa@redhat.com>
Thu, 19 Sep 2019 07:20:49 +0000 (09:20 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 25 Sep 2019 11:02:48 +0000 (13:02 +0200)
commit3377335508b4e5faa380cbb49d7c6ecd2276007f
tree3c40e519193a01fb8422a1c07980c290ef767287
parent6b39203fac30e2e4e0b943e932676439430cdf21
util: typedparam: Simplify handling of lists of typed parameters

Introduce a new set of helpers including a new data structure which
simplifies keeping and construction of lists of typed parameters.

The use of VIR_RESIZE_N in the virTypedParamsAdd API has performance
benefits but requires passing around 3 arguments. Use of them lead to a
set of macros with embedded jumps used in the qemu statistics code.

This patch introduces 'virTypedParamList' type which aggregates the
necessary list-keeping variables and also a new set of functions to add
new typed parameters to a list.

These new helpers use printf-like format string and arguments to format
the argument name as the stats code often uses indexed typed parameters.

The accessor function then allows extracting the typed parameter list in
the same format as virTypedParamsAdd* functions would do.

One additional benefit is also that the list function can easily be used
with VIR_AUTOPTR.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/libvirt_private.syms
src/util/virtypedparam.c
src/util/virtypedparam.h