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 virPerfPtr is declared using VIR_AUTOPTR,
the function virPerfFree will be run automatically on it when it
goes out of scope.
This commit also adds an intermediate typedef for virPerf
type for use with the cleanup macros.
Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
#endif
#include "virperf.h"
-#include "viralloc.h"
#include "virerror.h"
#include "virlog.h"
#include "virfile.h"
};
typedef struct virPerfEvent *virPerfEventPtr;
-struct virPerf {
+struct _virPerf {
struct virPerfEvent events[VIR_PERF_EVENT_LAST];
};
# define __VIR_PERF_H__
# include "virutil.h"
+# include "viralloc.h"
/* Some Intel processor families introduced some RDT (Resource Director
* Technology) features to monitor or control shared resource based on
VIR_ENUM_DECL(virPerfEvent);
-struct virPerf;
-typedef struct virPerf *virPerfPtr;
+struct _virPerf;
+typedef struct _virPerf virPerf;
+typedef virPerf *virPerfPtr;
virPerfPtr virPerfNew(void);
virPerfEventType type,
uint64_t *value);
+VIR_DEFINE_AUTOPTR_FUNC(virPerf, virPerfFree)
+
#endif /* __VIR_PERF_H__ */