Skip to content

Commit

Permalink
* qemud/buf.c src/xml.c: clarified virBufferGrow (and bufferGrow)
Browse files Browse the repository at this point in the history
  routines documentation and fixes a couple of places where this
  was misused as pointed by Daniel Berrange.
Daniel
  • Loading branch information
veillard committed Mar 21, 2007
1 parent bcf1632 commit f2ffea8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions qemud/buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f2ffea8

Please sign in to comment.