Re: [xml] Possible bug with xmlBufferPtr object?
- From: Daniel Veillard <veillard redhat com>
- To: Gilles Roy <groy qnx com>
- Cc: xml gnome org
- Subject: Re: [xml] Possible bug with xmlBufferPtr object?
- Date: Sat, 31 Jan 2009 08:14:15 +0100
On Thu, Jan 29, 2009 at 06:25:58PM -0500, Gilles Roy wrote:
I'm trying to make a copy of an in memory XML buffer. Based on the
sample code on the website (testWriter.c, the testXmlwriterMemory
function) I want to copy it to a buffer instead of writing to a file.
However, what I tried was:
char *xmldata = malloc(buf->use);
memcpy(xmldata, buf->content, buf->use);
However, this doesn't quite work. If buf->content is a string "abcd"
buf->use will be 4. This doesn't count for any kind of string
terminator. Should it?
Or does the application have to add the string terminator itself?
The terminator may not be present in a buffer and it's definitely
not accounted for in the size, like in any classic C API, I can't see
why you're expecting this.
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel veillard com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]