On Thursday, December 23, 2010 at 11:00:26 (-0800) Alan W. Irwin writes:
 > Maurice, do you know the origins of the free_mem macro in
 > include/plplotP.h?  That does deal with the NULL pointer case for
 > frees, but it also sets the pointer to NULL after every free so I
 > think this macro was meant to be used to guard against double frees of
 > the same memory. OTOH, another interpretation is the author of that
 > macro had run into a badly implemented free implementation that didn't
 > deal properly with a NULL pointer.

I wrote free_mem as syntactic sugar.  I don't think badly implemented free()'s
were part of the equation but I can't be sure.  So the "sugar" is as follows:
 - guard against a double free
 - related: since double free's become a no-op, if control flow becomes thorny
 you can put a free_mem in anywhere to be sure memory gets freed
 - the pointer is zeroed out since it bugged me to no end to have bogus
 pointers around.  Especially when debugging.

-- 
Maurice LeBrun

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to