提交 f2ffea85 编写于 作者: D Daniel Veillard

* 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.
Daniel
上级 bcf1632e
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> Wed Mar 21 10:52:06 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* acinclude.m4: Always use -Wp,-D_FORTIFY_SOURCE=2 -fexceptions * acinclude.m4: Always use -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
......
TODO: TODO:
- libvirt_virDomainSetMemory should check memory is > 0 - 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) - check how to better handle renaming of domains (xm rename and cache)
- UUID lookup in hash.c - UUID lookup in hash.c
......
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
/** /**
* bufferGrow: * bufferGrow:
* @buf: the buffer * @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 * Returns the new available space or -1 in case of error
*/ */
...@@ -72,7 +72,7 @@ bufferAdd(bufferPtr buf, const char *str, int len) ...@@ -72,7 +72,7 @@ bufferAdd(bufferPtr buf, const char *str, int len)
needSize = buf->use + len + 2; needSize = buf->use + len + 2;
if (needSize > buf->size) { if (needSize > buf->size) {
if (!bufferGrow(buf, needSize)) { if (!bufferGrow(buf, needSize - buf->use)) {
return (-1); return (-1);
} }
} }
...@@ -195,7 +195,7 @@ bufferStrcat(bufferPtr buf, ...) ...@@ -195,7 +195,7 @@ bufferStrcat(bufferPtr buf, ...)
unsigned int needSize = buf->use + len + 2; unsigned int needSize = buf->use + len + 2;
if (needSize > buf->size) { if (needSize > buf->size) {
if (!bufferGrow(buf, needSize)) if (!bufferGrow(buf, needSize - buf->use))
return -1; return -1;
} }
memcpy(&buf->content[buf->use], str, len); memcpy(&buf->content[buf->use], str, len);
......
...@@ -43,9 +43,9 @@ virXMLError(virConnectPtr conn, virErrorNumber error, const char *info, int valu ...@@ -43,9 +43,9 @@ virXMLError(virConnectPtr conn, virErrorNumber error, const char *info, int valu
/** /**
* virBufferGrow: * virBufferGrow:
* @buf: the buffer * @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 * Returns the new available space or -1 in case of error
*/ */
...@@ -99,7 +99,7 @@ virBufferAdd(virBufferPtr buf, const char *str, int len) ...@@ -99,7 +99,7 @@ virBufferAdd(virBufferPtr buf, const char *str, int len)
needSize = buf->use + len + 2; needSize = buf->use + len + 2;
if (needSize > buf->size) { if (needSize > buf->size) {
if (!virBufferGrow(buf, needSize)) { if (!virBufferGrow(buf, needSize - buf->use)) {
return (-1); return (-1);
} }
} }
...@@ -200,7 +200,7 @@ virBufferStrcat(virBufferPtr buf, ...) ...@@ -200,7 +200,7 @@ virBufferStrcat(virBufferPtr buf, ...)
unsigned int needSize = buf->use + len + 2; unsigned int needSize = buf->use + len + 2;
if (needSize > buf->size) { if (needSize > buf->size) {
if (!virBufferGrow(buf, needSize)) if (!virBufferGrow(buf, needSize - buf->use))
return -1; return -1;
} }
memcpy(&buf->content[buf->use], str, len); memcpy(&buf->content[buf->use], str, len);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册