]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
util: Make sure the comment about virBufferAddBuffer is true
authorMartin Kletzander <mkletzan@redhat.com>
Fri, 13 Mar 2015 15:41:42 +0000 (16:41 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 17 Mar 2015 11:03:33 +0000 (12:03 +0100)
Change it so it really *always* eats the @toadd buffer.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/util/virbuffer.c

index 96a0f16d57ccc8a158b94631514a2056b608b096..0089d1b42c4ea2a78a36c2d7269a61741b7fc325 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * virbuffer.c: buffers for libvirt
  *
- * Copyright (C) 2005-2008, 2010-2014 Red Hat, Inc.
+ * Copyright (C) 2005-2008, 2010-2015 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -188,23 +188,27 @@ virBufferAddBuffer(virBufferPtr buf, virBufferPtr toadd)
 {
     unsigned int needSize;
 
-    if (!buf || !toadd)
+    if (!toadd)
         return;
 
+    if (!buf)
+        goto done;
+
     if (buf->error || toadd->error) {
         if (!buf->error)
             buf->error = toadd->error;
-        virBufferFreeAndReset(toadd);
-        return;
+        goto done;
     }
 
     needSize = buf->use + toadd->use;
     if (virBufferGrow(buf, needSize - buf->use) < 0)
-        return;
+        goto done;
 
     memcpy(&buf->content[buf->use], toadd->content, toadd->use);
     buf->use += toadd->use;
     buf->content[buf->use] = '\0';
+
+ done:
     virBufferFreeAndReset(toadd);
 }