]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: buffer: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
authorSukrit Bhatnagar <skrtbhtngr@gmail.com>
Tue, 24 Jul 2018 15:52:04 +0000 (21:22 +0530)
committerErik Skultety <eskultet@redhat.com>
Fri, 27 Jul 2018 15:19:13 +0000 (17:19 +0200)
commit96fbf6df90335c1f9315fc25162711fd632d4dab
treec9bf8b41897baccde9b7fd52a8660fb7c22315ed
parentd261ed2fb1df95f6c7698b9321a82078a7335112
util: buffer: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC

Using the new VIR_DEFINE_AUTOPTR_FUNC macro defined in
src/util/viralloc.h, define a new wrapper around an existing
cleanup function which will be called when a variable declared
with VIR_AUTOPTR macro goes out of scope. Also, drop the redundant
viralloc.h include, since that has moved from the source module into
the header.

When variables of type virBufferPtr and virBufferEscapePairPtr
are declared using VIR_AUTOPTR, the functions virBufferFreeAndReset
and virBufferEscapePairFree, respectively, will be run automatically
on them when they go out of scope.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/util/virbuffer.c
src/util/virbuffer.h