70 lines
2.3 KiB
Diff
70 lines
2.3 KiB
Diff
From 47babc4b1ad1c615df10385bbaafdd30d9359b7a Mon Sep 17 00:00:00 2001
|
|
Message-Id: <47babc4b1ad1c615df10385bbaafdd30d9359b7a@dist-git>
|
|
From: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
|
|
Date: Tue, 30 Jul 2019 15:30:46 +0200
|
|
Subject: [PATCH] util: command: define cleanup function using
|
|
VIR_DEFINE_AUTOPTR_FUNC
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
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 virCommandPtr is declared using VIR_AUTOPTR,
|
|
the function virCommandFree 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>
|
|
(cherry picked from commit 7e343758920cc954d448b6b14df5707bcd0dbd20)
|
|
|
|
Prerequisite of: https://bugzilla.redhat.com/show_bug.cgi?id=1721434
|
|
|
|
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
Message-Id: <40a1fc21abc06c057574a4616eef9981dbfb25dd.1564493409.git.mprivozn@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
---
|
|
src/util/vircommand.c | 1 -
|
|
src/util/vircommand.h | 2 ++
|
|
2 files changed, 2 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
|
|
index c2b8a1a3c3..d328431373 100644
|
|
--- a/src/util/vircommand.c
|
|
+++ b/src/util/vircommand.c
|
|
@@ -44,7 +44,6 @@
|
|
|
|
#define __VIR_COMMAND_PRIV_H_ALLOW__
|
|
#include "vircommandpriv.h"
|
|
-#include "viralloc.h"
|
|
#include "virerror.h"
|
|
#include "virutil.h"
|
|
#include "virlog.h"
|
|
diff --git a/src/util/vircommand.h b/src/util/vircommand.h
|
|
index 883e212959..90bcc6c89d 100644
|
|
--- a/src/util/vircommand.h
|
|
+++ b/src/util/vircommand.h
|
|
@@ -24,6 +24,7 @@
|
|
|
|
# include "internal.h"
|
|
# include "virbuffer.h"
|
|
+# include "viralloc.h"
|
|
|
|
typedef struct _virCommand virCommand;
|
|
typedef virCommand *virCommandPtr;
|
|
@@ -218,5 +219,6 @@ int virCommandRunNul(virCommandPtr cmd,
|
|
virCommandRunNulFunc func,
|
|
void *data);
|
|
|
|
+VIR_DEFINE_AUTOPTR_FUNC(virCommand, virCommandFree)
|
|
|
|
#endif /* __VIR_COMMAND_H__ */
|
|
--
|
|
2.22.0
|
|
|