]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: buffer: Introduce VIR_AUTOCLEAN function for virBuffer
authorPeter Krempa <pkrempa@redhat.com>
Thu, 21 Feb 2019 15:37:50 +0000 (16:37 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 22 Feb 2019 09:05:45 +0000 (10:05 +0100)
commit55ee6ac8de1fc716e86c29f45d515bd8aac7ad3d
treeb3b1fd7e2eda60a6648e2a34d7bf29cefd65574c
parentc73f752e46494b64f054a5c539dfe5b5ad145518
util: buffer: Introduce VIR_AUTOCLEAN function for virBuffer

virBuffer is almost always stack-allocated, but requires freeing of the
internals on error. Introduce a VIR_AUTOCLEAN function to deal with
this.

Along with the addition add a test which would leak the buffer contents
if it weren't autocleaned.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
src/util/virbuffer.h
tests/virbuftest.c