util/virarch.c \
util/viratomic.c \
util/viratomic.h \
+ util/virautoclean.h \
util/virbitmap.c \
util/virbuffer.c \
util/vircgroup.c \
util/viralloc.h \
util/viratomic.c \
util/viratomic.h \
+ util/virautoclean.h \
util/virbitmap.c \
util/virbitmap.h \
util/virbuffer.c \
# include "internal.h"
# include "domain_conf.h"
# include "viralloc.h"
+# include "virautoclean.h"
typedef const char * (*virDomainCapsValToStr)(int value);
# include "device_conf.h"
# include "object_event.h"
# include "storage_adapter_conf.h"
+# include "virautoclean.h"
# include <libxml/tree.h>
# include "domain_conf.h"
# include "viralloc.h"
# include "qemu_conf.h"
+# include "virautoclean.h"
typedef struct _qemuFirmware qemuFirmware;
typedef qemuFirmware *qemuFirmwarePtr;
# include "virxml.h"
# include "qemu_monitor.h"
# include "qemu_conf.h"
+# include "virautoclean.h"
typedef enum {
QEMU_MIGRATION_CAP_XBZRLE,
util/virauth.h \
util/virauthconfig.c \
util/virauthconfig.h \
+ util/virautoclean.h \
util/virbitmap.c \
util/virbitmap.h \
util/virbuffer.c \
void virAllocTestOOM(int n, int m);
void virAllocTestHook(void (*func)(int, void*), void *data);
-# define VIR_AUTOPTR_FUNC_NAME(type) type##AutoPtrFree
-
-/**
- * VIR_DEFINE_AUTOPTR_FUNC:
- * @type: type of the variable to be freed automatically
- * @func: cleanup function to be automatically called
- *
- * This macro defines a function for automatic freeing of
- * resources allocated to a variable of type @type. This newly
- * defined function works as a necessary wrapper around @func.
- */
-# define VIR_DEFINE_AUTOPTR_FUNC(type, func) \
- static inline void VIR_AUTOPTR_FUNC_NAME(type)(type **_ptr) \
- { \
- if (*_ptr) \
- (func)(*_ptr); \
- *_ptr = NULL; \
- }
-
-# define VIR_AUTOCLEAN_FUNC_NAME(type) type##AutoClean
-
-/**
- * VIR_DEFINE_AUTOCLEAN_FUNC:
- * @type: type of the variable to be cleared automatically
- * @func: cleanup function to be automatically called
- *
- * This macro defines a function for automatic clearing of
- * resources in a stack'd variable of type @type. Note that @func must
- * take pointer to @type.
- */
-# define VIR_DEFINE_AUTOCLEAN_FUNC(type, func) \
- static inline void VIR_AUTOCLEAN_FUNC_NAME(type)(type *_ptr) \
- { \
- (func)(_ptr); \
- }
-
/**
* VIR_AUTOFREE:
* @type: type of the variable to be freed automatically
*/
# define VIR_AUTOFREE(type) __attribute__((cleanup(virFree))) type
-/**
- * VIR_AUTOPTR:
- * @type: type of the variable to be freed automatically
- *
- * Macro to automatically free the memory allocated to
- * the variable declared with it by calling the function
- * defined by VIR_DEFINE_AUTOPTR_FUNC when the variable
- * goes out of scope.
- *
- * Note that this macro must NOT be used with vectors! The freeing function
- * will not free any elements beyond the first.
- */
-# define VIR_AUTOPTR(type) \
- __attribute__((cleanup(VIR_AUTOPTR_FUNC_NAME(type)))) type *
-
-/**
- * VIR_AUTOCLEAN:
- * @type: type of the variable to be cleared automatically
- *
- * Macro to automatically call clearing function registered for variable of @type
- * when the variable goes out of scope.
- * The cleanup function is registered by VIR_DEFINE_AUTOCLEAN_FUNC macro for
- * the given type.
- *
- * Note that this macro must NOT be used with vectors! The cleaning function
- * will not clean any elements beyond the first.
- */
-# define VIR_AUTOCLEAN(type) \
- __attribute__((cleanup(VIR_AUTOCLEAN_FUNC_NAME(type)))) type
-
#endif /* LIBVIRT_VIRALLOC_H */
# include "internal.h"
# include "viralloc.h"
+# include "virautoclean.h"
typedef struct _virAuthConfig virAuthConfig;
typedef virAuthConfig *virAuthConfigPtr;
--- /dev/null
+/*
+ * virautoclean.h: automatic scope-based memory clearing helper macros for
+ * use in header files
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef LIBVIRT_VIRAUTOCLEAN_H
+# define LIBVIRT_VIRAUTOCLEAN_H
+
+# define VIR_AUTOPTR_FUNC_NAME(type) type##AutoPtrFree
+
+/**
+ * VIR_DEFINE_AUTOPTR_FUNC:
+ * @type: type of the variable to be freed automatically
+ * @func: cleanup function to be automatically called
+ *
+ * This macro defines a function for automatic freeing of
+ * resources allocated to a variable of type @type. This newly
+ * defined function works as a necessary wrapper around @func.
+ */
+# define VIR_DEFINE_AUTOPTR_FUNC(type, func) \
+ static inline void VIR_AUTOPTR_FUNC_NAME(type)(type **_ptr) \
+ { \
+ if (*_ptr) \
+ (func)(*_ptr); \
+ *_ptr = NULL; \
+ }
+
+# define VIR_AUTOCLEAN_FUNC_NAME(type) type##AutoClean
+
+/**
+ * VIR_DEFINE_AUTOCLEAN_FUNC:
+ * @type: type of the variable to be cleared automatically
+ * @func: cleanup function to be automatically called
+ *
+ * This macro defines a function for automatic clearing of
+ * resources in a stack'd variable of type @type. Note that @func must
+ * take pointer to @type.
+ */
+# define VIR_DEFINE_AUTOCLEAN_FUNC(type, func) \
+ static inline void VIR_AUTOCLEAN_FUNC_NAME(type)(type *_ptr) \
+ { \
+ (func)(_ptr); \
+ }
+
+/**
+ * VIR_AUTOPTR:
+ * @type: type of the variable to be freed automatically
+ *
+ * Macro to automatically free the memory allocated to
+ * the variable declared with it by calling the function
+ * defined by VIR_DEFINE_AUTOPTR_FUNC when the variable
+ * goes out of scope.
+ *
+ * Note that this macro must NOT be used with vectors! The freeing function
+ * will not free any elements beyond the first.
+ */
+# define VIR_AUTOPTR(type) \
+ __attribute__((cleanup(VIR_AUTOPTR_FUNC_NAME(type)))) type *
+
+/**
+ * VIR_AUTOCLEAN:
+ * @type: type of the variable to be cleared automatically
+ *
+ * Macro to automatically call clearing function registered for variable of @type
+ * when the variable goes out of scope.
+ * The cleanup function is registered by VIR_DEFINE_AUTOCLEAN_FUNC macro for
+ * the given type.
+ *
+ * Note that this macro must NOT be used with vectors! The cleaning function
+ * will not clean any elements beyond the first.
+ */
+# define VIR_AUTOCLEAN(type) \
+ __attribute__((cleanup(VIR_AUTOCLEAN_FUNC_NAME(type)))) type
+
+#endif /* LIBVIRT_VIRAUTOCLEAN_H */
# include "internal.h"
# include "viralloc.h"
+# include "virautoclean.h"
# include <sys/types.h>
# include "internal.h"
# include "viralloc.h"
+# include "virautoclean.h"
/**
# include "internal.h"
# include "virbuffer.h"
# include "viralloc.h"
+# include "virautoclean.h"
typedef struct _virCommand virCommand;
typedef virCommand *virCommandPtr;
# include "internal.h"
# include "viralloc.h"
+# include "virautoclean.h"
# define VIR_ERROR_MAX_LENGTH 1024
# include "virbitmap.h"
# include "virstoragefile.h"
# include "viralloc.h"
+# include "virautoclean.h"
typedef enum {
VIR_FILE_CLOSE_PRESERVE_ERRNO = 1 << 0,
# include "internal.h"
# include "viralloc.h"
+# include "virautoclean.h"
typedef struct _virFirewall virFirewall;
typedef virFirewall *virFirewallPtr;
# include "viralloc.h"
+# include "virautoclean.h"
/*
* The hash table.
# include "virbitmap.h"
# include "viralloc.h"
# include "virbuffer.h"
+# include "virautoclean.h"
# include <stdarg.h>
# include "internal.h"
# include "viralloc.h"
+# include "virautoclean.h"
# define VIR_MAC_BUFLEN 6
# define VIR_MAC_HEXLEN (VIR_MAC_BUFLEN * 2)
# include "virobject.h"
# include "virutil.h"
# include "viralloc.h"
+# include "virautoclean.h"
typedef enum {
VIR_MDEV_MODEL_TYPE_VFIO_PCI = 0,
# include "virpci.h"
# include "virnetdevvlan.h"
# include "viralloc.h"
+# include "virautoclean.h"
# ifdef HAVE_STRUCT_IFREQ
typedef struct ifreq virIfreq;
# define LIBVIRT_VIRNETDEVIP_H
# include "virsocketaddr.h"
+# include "virautoclean.h"
typedef struct _virNetDevIPAddr virNetDevIPAddr;
typedef virNetDevIPAddr *virNetDevIPAddrPtr;
# include <virutil.h>
# include "viralloc.h"
+# include "virautoclean.h"
typedef enum {
VIR_NATIVE_VLAN_MODE_DEFAULT = 0,
# include "internal.h"
# include "virmacaddr.h"
# include "viralloc.h"
+# include "virautoclean.h"
# if defined(__linux__) && defined(HAVE_LIBNL)
# include "virobject.h"
# include "virutil.h"
# include "viralloc.h"
+# include "virautoclean.h"
typedef struct _virPCIDevice virPCIDevice;
typedef virPCIDevice *virPCIDevicePtr;
# include "virutil.h"
# include "viralloc.h"
+# include "virautoclean.h"
/* Some Intel processor families introduced some RDT (Resource Director
* Technology) features to monitor or control shared resource based on
# include "internal.h"
# include "virobject.h"
# include "viralloc.h"
+# include "virautoclean.h"
typedef struct _virSCSIDevice virSCSIDevice;
typedef virSCSIDevice *virSCSIDevicePtr;
# include "virobject.h"
# include "virutil.h"
# include "viralloc.h"
+# include "virautoclean.h"
typedef struct _virSCSIVHostDevice virSCSIVHostDevice;
typedef virSCSIVHostDevice *virSCSIVHostDevicePtr;
# include "internal.h"
# include "viralloc.h"
+# include "virautoclean.h"
/* On architectures which lack these limits, define them (ie. Cygwin).
* Note that the libvirt code should be robust enough to handle the
# include "virstorageencryption.h"
# include "virutil.h"
# include "virsecret.h"
+# include "virautoclean.h"
/* Minimum header size required to probe all known formats with
* virStorageFileProbeFormat, or obtain metadata from a known format.
# include "internal.h"
# include "virobject.h"
# include "viralloc.h"
+# include "virautoclean.h"
# define USB_DEVFS "/dev/bus/usb/"
# include <libxml/relaxng.h>
# include "virbuffer.h"
+# include "virautoclean.h"
int virXPathBoolean(const char *xpath,
xmlXPathContextPtr ctxt);