It's been customary to set pointers to NULL after freeing them in
object (and module) exit functions. I'd like to question whether that
really makes much sense.
The object storage is only going to be freed just afterwards anyway
(same goes for dynamically loaded modules), so the only bugs that this
kind of "hygiene" could help nail is if destruct_object or
exit_dynamic_load misbehaves. That's a bit unlikely by now, and anyway
it's an awful lot of code everywhere just for that. The assignments
are not even inside #ifdef PIKE_DEBUG as such belts-and-suspenders
things usually are. Or am I missing something here?
Also, when a pointer is not supposed to be used anymore, I usually do
something like this instead:
free (x->foo);
#ifdef PIKE_DEBUG
x->foo = (void *) (ptrdiff_t) -1;
#endif
That is more likely to trig a helpful coredump if the pointer is being
used incorrectly.