1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-09 01:18:00 +03:00

util: bitmap: 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 a variable of type virBitmapPtr is declared using
VIR_AUTOPTR, the function virBitmapFree will be run
automatically on it when it goes out of scope.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Sukrit Bhatnagar 2018-07-13 23:25:00 +05:30 committed by Erik Skultety
parent c450b55a65
commit a3c915e662
2 changed files with 3 additions and 1 deletions

View File

@ -31,7 +31,6 @@
#include <sys/types.h>
#include "virbitmap.h"
#include "viralloc.h"
#include "virbuffer.h"
#include "c-ctype.h"
#include "count-one-bits.h"

View File

@ -25,6 +25,7 @@
# define __BITMAP_H__
# include "internal.h"
# include "viralloc.h"
# include <sys/types.h>
@ -155,4 +156,6 @@ void virBitmapSubtract(virBitmapPtr a, virBitmapPtr b)
void virBitmapShrink(virBitmapPtr map, size_t b);
VIR_DEFINE_AUTOPTR_FUNC(virBitmap, virBitmapFree)
#endif