]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
* qemud/buf.c src/xml.c: clarified virBufferGrow (and bufferGrow)
authorDaniel Veillard <veillard@redhat.com>
Wed, 21 Mar 2007 15:24:56 +0000 (15:24 +0000)
committerDaniel Veillard <veillard@redhat.com>
Wed, 21 Mar 2007 15:24:56 +0000 (15:24 +0000)
  routines documentation and fixes a couple of places where this
  was misused as pointed by Daniel Berrange.
Daniel

ChangeLog
TODO
qemud/buf.c
src/xml.c

index 7356eda5f3fbff57a965177f8471111bfd432afc..a3b8df7c7352ae7210edf2d21e2acaab542c8a54 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Mar 21 16:31:29 CET 2007 Daniel Veillard <veillard@redhat.com>
+
+       * qemud/buf.c src/xml.c: clarified virBufferGrow (and bufferGrow)
+         routines documentation and fixes a couple of places where this
+         was misused as pointed by Daniel Berrange.
+
 Wed Mar 21 10:52:06 EST 2007 Daniel P. Berrange <berrange@redhat.com>
 
        * acinclude.m4: Always use -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
diff --git a/TODO b/TODO
index b739d7f3271c7f3227a368e3ead1892cc75dfe8b..7d21fae43c66be0f6af4a630f9a892e9b060ce7f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,5 +1,6 @@
 TODO:
 - libvirt_virDomainSetMemory should check memory is > 0
+- remove calls from sprintf and use snprintf
 - check how to better handle renaming of domains (xm rename and cache)
 
 - UUID lookup in hash.c
index 61c5875cae30520cf1a1f54b2e51c71ae8f104ab..2ce2462a692d692847a1c2080ea4b6fd68f02376 100644 (file)
@@ -19,9 +19,9 @@
 /**
  * bufferGrow:
  * @buf:  the buffer
- * @len:  the minimum free size to allocate
+ * @len:  the minimum free size to allocate on top of existing used space
  *
- * Grow the available space of an XML buffer.
+ * Grow the available space of a buffer to at least @len bytes.
  *
  * Returns the new available space or -1 in case of error
  */
@@ -72,7 +72,7 @@ bufferAdd(bufferPtr buf, const char *str, int len)
 
     needSize = buf->use + len + 2;
     if (needSize > buf->size) {
-        if (!bufferGrow(buf, needSize)) {
+        if (!bufferGrow(buf, needSize - buf->use)) {
             return (-1);
         }
     }
@@ -195,7 +195,7 @@ bufferStrcat(bufferPtr buf, ...)
         unsigned int needSize = buf->use + len + 2;
 
         if (needSize > buf->size) {
-            if (!bufferGrow(buf, needSize))
+            if (!bufferGrow(buf, needSize - buf->use))
                 return -1;
         }
         memcpy(&buf->content[buf->use], str, len);
index c67dc3521ef25f37f5e55e3b22ea24ac83cc0c37..6ec4938fbec245dc377502bb3d888984820d0e08 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -43,9 +43,9 @@ virXMLError(virConnectPtr conn, virErrorNumber error, const char *info, int valu
 /**
  * virBufferGrow:
  * @buf:  the buffer
- * @len:  the minimum free size to allocate
+ * @len:  the minimum free size to allocate on top of existing used space
  *
- * Grow the available space of an XML buffer.
+ * Grow the available space of an XML buffer to at least @len bytes.
  *
  * Returns the new available space or -1 in case of error
  */
@@ -99,7 +99,7 @@ virBufferAdd(virBufferPtr buf, const char *str, int len)
 
     needSize = buf->use + len + 2;
     if (needSize > buf->size) {
-        if (!virBufferGrow(buf, needSize)) {
+        if (!virBufferGrow(buf, needSize - buf->use)) {
             return (-1);
         }
     }
@@ -200,7 +200,7 @@ virBufferStrcat(virBufferPtr buf, ...)
         unsigned int needSize = buf->use + len + 2;
 
         if (needSize > buf->size) {
-            if (!virBufferGrow(buf, needSize))
+            if (!virBufferGrow(buf, needSize - buf->use))
                 return -1;
         }
         memcpy(&buf->content[buf->use], str, len);