[xml] Understanding memory usage and cross-references

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)

I am wondering why the code isn't

   if (keyd->nsList != NULL)

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.



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