The Merciless Lord of Everything wrote: > But it made me wonder, how to make a Circle-Free, ie, imitiate the FreeBSD > free(). Problem is how to look at what you're trying to free, so far I > would imagine the function to look something like this (Not this will > *NOT* work, it's only in concept): Use a macro, that way you can log the file and line number as follows (note: untested code)... #define SAFE_FREE(ptr) ((ptr) ? free(ptr) : \ (log("SYSERR: Attempting to free a NULL pointer at %s: %d", __FILE__, __LINE__))) That should pretty much do what you want, the only problem is it will still attempt to free the memory if the arg is not NULL but is invalid (ie, a pointer that was not initialized or one that was already freed but not set to NULL however, most of the seg faults that result from free (imho) are the rusult of trying to free a NULL pointer. Regards, Peter +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/10/01 PDT