[xml] Possible bug with xmlBufferPtr object?



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?


Thanks,
Gilles`



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]