mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
util: cgroup: 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 virCgroupPtr is declared using VIR_AUTOPTR, the function virCgroupFree will be run automatically on it when it goes out of scope. This commit also adds an intermediate typedef for virCgroup type for use with the cleanup macros. Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
0f80c71822
commit
4da4a9fe0c
@ -50,7 +50,6 @@
|
||||
#include "vircgrouppriv.h"
|
||||
|
||||
#include "virutil.h"
|
||||
#include "viralloc.h"
|
||||
#include "virerror.h"
|
||||
#include "virlog.h"
|
||||
#include "virfile.h"
|
||||
|
@ -27,9 +27,11 @@
|
||||
|
||||
# include "virutil.h"
|
||||
# include "virbitmap.h"
|
||||
# include "viralloc.h"
|
||||
|
||||
struct virCgroup;
|
||||
typedef struct virCgroup *virCgroupPtr;
|
||||
struct _virCgroup;
|
||||
typedef struct _virCgroup virCgroup;
|
||||
typedef virCgroup *virCgroupPtr;
|
||||
|
||||
enum {
|
||||
VIR_CGROUP_CONTROLLER_CPU,
|
||||
@ -297,4 +299,7 @@ int virCgroupSetOwner(virCgroupPtr cgroup,
|
||||
int virCgroupHasEmptyTasks(virCgroupPtr cgroup, int controller);
|
||||
|
||||
bool virCgroupControllerAvailable(int controller);
|
||||
|
||||
VIR_DEFINE_AUTOPTR_FUNC(virCgroup, virCgroupFree)
|
||||
|
||||
#endif /* __VIR_CGROUP_H__ */
|
||||
|
@ -42,7 +42,7 @@ struct virCgroupController {
|
||||
char *placement;
|
||||
};
|
||||
|
||||
struct virCgroup {
|
||||
struct _virCgroup {
|
||||
char *path;
|
||||
|
||||
struct virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST];
|
||||
|
Loading…
x
Reference in New Issue
Block a user