* 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
This commit is contained in:
Daniel Veillard 2007-03-21 15:24:56 +00:00
parent bcf1632ee6
commit f2ffea858c
4 changed files with 15 additions and 8 deletions

View File

@ -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

1
TODO
View File

@ -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

View 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);

View File

@ -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);