[xml] Understanding memory usage and cross-references
- From: Patrick O'Brien <pobrien9 comcast net>
- To: xml gnome org
- Subject: [xml] Understanding memory usage and cross-references
- Date: Sun, 02 May 2010 11:02:03 -0700
Hello list -
in the source file keys.c, in the function xsltFreeKeyDef(xsltKeyDefPtr
keyd), near the end of the function there are the lines:
if (keyd->nsList != NULL)
xmlFree(keyd->nsList);
I am wondering why the code isn't
if (keyd->nsList != NULL)
xmlFreeNsList(keyd->nsList);
A runtime type inspection mechanism could allow for type recognition on
free(), but I believe this is not the case here.
*****
In addition, the structure _xsltKeyDef { } has a data member named
xmlNodePtr inst, and this is not freed in xsltFreeKeyDef(); I assume it
is so because inst is a reference to a structure allocated elsewhere
that will be freed elsewhere.
This is by way of remarking that there is no obvious way to know what
sub-structures are allocated from a given structure, and what structures
are just working references, short of reading all related code.
The motivation for these observations is a review of the code en route
to a better understanding of the cost involved in writing a serializer
for the xsltStylesheet structure.
Regards,
pob
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]