[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [xml] Text writer memory won't write
- From: Mike Mueller <mike subfocal net>
- To: xml gnome org
- Subject: Re: [xml] Text writer memory won't write
- Date: Thu, 18 Jan 2007 22:57:25 -0500
On Thu, Jan 18, 2007 at 07:18:51PM -0800, William M. Brack wrote:
> Mike Mueller wrote:
> > I'm using a memory text writer as in the function testXmlwriterMemory()
> > here: http://www.xmlsoft.org/examples/testWriter.c
> >
> > I create a buffer, a writer, start a document, write some elements, end
> > the document. Every one of the write calls returns 0 (no bytes written,
> > but no errors either).
> >
> > Examining the buffer in GDB shows it empty:
> >
> > $10 = {
> > content = 0x3d6380 "",
> > use = 0,
> > size = 4096,
> > alloc = XML_BUFFER_ALLOC_EXACT
> > }
> >
> > Examining the writer's out->context field, it's a void pointer with the
> > same address as the buffer I handed it when the writer was created.
> >
> > Examining the writer's out->buffer field shows it contains all the data
> > I wrote!
> >
> > $14 = {
> > content = 0x3d73f8 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>...",
> > use = 192,
> > size = 4096,
> > alloc = XML_BUFFER_ALLOC_DOUBLEIT
> > }
> >
> > I truncated the content field because it was large, but it had my
> > complete XML document inside it. So the writer is apparently doing most
> > of its job, except it won't put any data into my buffer.
> >
> > Anyone know why this would happen?
> >
> > --
> > Mike Mueller
> > mike subfocal net
>
> If you compile and run the test program you reference, does it work OK
> (it certainly does for me)? Assuming that it does, then what are the
> differences between your code and the function in the test program? What
> does gdb show for the test program buffer? When you say "Every one of
> the write calls returns 0" are you describing the return code from a
> fuction like xmlTextWriterStartElement? If so, 0 means success, and a
> negative value means error.
>
> Bill
Thanks, I guess that should have been my next step.
I compiled the test program and it works fine. It turns out the data
gets dumped into the buffer when you call xmlFreeTextWriter. I wasn't
freeing the writer until much after I tried to find my data in the
buffer. Of course, the documentation for this function simply says:
Deallocate all the resources associated to the writer
Yay for confusing APIs.
Mike
--
Mike Mueller
mike subfocal net
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]