[Expat-discuss] New API: XML_FreeContentModel

Fred L. Drake, Jr. fdrake at acm.org
Thu Jan 16 13:05:04 EST 2003


On Wed, 2003-01-15 at 08:38, Karl Waclawek wrote:
 > 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.

Karl:
 > As an alternative solution we have also had a request to add an API
 > that returns the memory handling suite of function pointers, like
 > 
 > 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.

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, 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 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!


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation



More information about the Expat-discuss mailing list