[Expat-discuss] New API: XML_FreeContentModel
Karl Waclawek
karl at waclawek.net
Thu Jan 16 13:59:01 EST 2003
> > XMLPARSEAPI(void)
> > XML_FreeContentModel(XML_Parser parser, XML_Content *model);
> >
> > This not only solves the problem above, but is also better from
> > a design perspective, since currently the application using Expat
> > has to know that Expat allocated the content model in one contiguous
> > chunk of memory. The API above hides that implementation detail.
>
> Jeremy Kloth writes:
> > +1 for this
>
> +1 here also.
>
<snip>
> > XMLPARSEAPI(const XML_Memory_Handling_Suite *)
> > XML_GetMemSuite(XML_Parser parser);
> >
> > allowing the application to free the content model natively.
> > However, this would not hide the implementation details of
> > how the content model is allocated.
>
> Jeremy:
> > -1 for using this to free the content model.
>
> -1 here as well, for this use of the returned mem-suite thingie.
>
> > Instead of returning the memsuite, how about a trio of functions like
> >
> > XMLPARSEAPI(void *)
> > XML_MemMalloc(XML_Parser parser, size_t size);
> >
> > XMLPARSEAPI(void *)
> > XML_MemRealloc(XML_Parser parser, void *ptr, size_t size);
> >
> > XMLPARSEAPI(void)
> > XML_MemFree(XML_Parser parser, void *ptr);
>
> +1.
Does thise mean you guys want both? XML_FreeContentModel and the
memory functions?
> This is much better as far as I'm concerned, and alleviates the issues
> I had with the XML_GetMemSuite() approach. Since it solves all the
> use cases I know of,
Which use cases did you think of? And what were your issues?
> I'd be happy to see this done as part of 1.95.6.
> It also allows Expat to add a layer between the memory suite functions
> and what it returns if that proves reasonable (for example, by using
> some sort or arena-based allocator which gets arenas from the memory
> suite, but does everything else internally).
I just remembered we discussed another memory handling related
topic a while back. The goal was to find a way for Expat to track
memory allocations in order to be able to counteract one
of those "a million laughs" XML attacks. However, I believe we
found that we would have to add an XML_Parser parameter to
the memory (de)allocation calls to be able to track this on
a per instance basis.
Any thoughts? Should this be considered?
> I should be able to implement this sometime this weekend if Karl
> doesn't beat me to it. ;-) 1.95.6 might not be too far off!
So, just to make sure: what is the final proposal?
Karl
More information about the Expat-discuss
mailing list