Create typedefs virBufferEscapePair and virBufferEscapePairPtr
for struct _virBufferEscapePair for cleaner code and for use
with cleanup macros.
Also create a dedicated Free helper virBufferEscapePairFree.
Signed-off-by: Sukrit Bhatnagar <skrtbhtngr(a)gmail.com>
---
src/util/virbuffer.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c
index 3d6defb..8076cd3 100644
--- a/src/util/virbuffer.c
+++ b/src/util/virbuffer.c
@@ -648,11 +648,23 @@ virBufferEscape(virBufferPtr buf, char escape, const char
*toescape,
}
+typedef struct _virBufferEscapePair virBufferEscapePair;
+typedef virBufferEscapePair *virBufferEscapePairPtr;
+
struct _virBufferEscapePair {
char escape;
char *toescape;
};
+static void
+virBufferEscapePairFree(virBufferEscapePairPtr pair)
+{
+ if (!pair)
+ return;
+
+ VIR_FREE(pair);
+}
+
/**
* virBufferEscapeN:
@@ -678,8 +690,8 @@ virBufferEscapeN(virBufferPtr buf,
char *escaped = NULL;
char *out;
const char *cur;
- struct _virBufferEscapePair escapeItem;
- struct _virBufferEscapePair *escapeList = NULL;
+ virBufferEscapePair escapeItem;
+ virBufferEscapePairPtr escapeList = NULL;
size_t nescapeList = 0;
va_list ap;
--
1.8.3.1