Split out the worker loop into a separate function and export it. --- src/libvirt_private.syms | 1 + src/util/virbuffer.c | 27 +++++++++++++++++++++------ src/util/virbuffer.h | 2 ++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fa2cd08fe..588b76b43 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1345,6 +1345,7 @@ virBufferFreeAndReset; virBufferGetIndent; virBufferSetIndent; virBufferStrcat; +virBufferStrcatVArgs; virBufferTrim; virBufferURIEncodeString; virBufferUse; diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c index f07b119c0..28a291bb0 100644 --- a/src/util/virbuffer.c +++ b/src/util/virbuffer.c @@ -831,6 +831,26 @@ virBufferEscapeShell(virBufferPtr buf, const char *str) } /** + * virBufferStrcatVArgs: + * @buf: the buffer to append to + * @ap: variable argument structure + * + * See virBufferStrcat. + */ +void +virBufferStrcatVArgs(virBufferPtr buf, + va_list ap) +{ + char *str; + + if (buf->error) + return; + + while ((str = va_arg(ap, char *)) != NULL) + virBufferAdd(buf, str, -1); +} + +/** * virBufferStrcat: * @buf: the buffer to append to * @...: the variable list of strings, the last argument must be NULL @@ -842,14 +862,9 @@ void virBufferStrcat(virBufferPtr buf, ...) { va_list ap; - char *str; - - if (buf->error) - return; va_start(ap, buf); - while ((str = va_arg(ap, char *)) != NULL) - virBufferAdd(buf, str, -1); + virBufferStrcatVArgs(buf, ap); va_end(ap); } diff --git a/src/util/virbuffer.h b/src/util/virbuffer.h index 7a7014aa7..f34217968 100644 --- a/src/util/virbuffer.h +++ b/src/util/virbuffer.h @@ -80,6 +80,8 @@ void virBufferVasprintf(virBufferPtr buf, const char *format, va_list ap) ATTRIBUTE_FMT_PRINTF(2, 0); void virBufferStrcat(virBufferPtr buf, ...) ATTRIBUTE_SENTINEL; +void virBufferStrcatVArgs(virBufferPtr buf, va_list ap); + void virBufferEscape(virBufferPtr buf, char escape, const char *toescape, const char *format, const char *str); void virBufferEscapeN(virBufferPtr buf, const char *format, -- 2.13.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list