Brief discussion on chat concluded that
the freeIntRepProc of any Tcl_ObjType
ought to set the typePtr field to NULL so
that the Tcl_Obj is not left in an inconsistent
state.
At least some freeIntRepProc's in the
core fail to meet this expectation. Search and destroy.
Agreed, but shouln't that be the responsibility of the
TclFreeIntRep macro? Currently, a lot of TclFreeIntRep
calls are followed by setting (objPtr)->typePtr to NULL!
The freeIntRepProc is not supposed to be called directly,
so doing it in TclFreeIntRep has the advantage that
it works for freeIntRep functions outside of the core as well.
Adding it to the TclFreeIntRep macro is
a fine idea too, but can only help the callers
of the macro. Since the macro is private, the
only callers ought to be within Tcl itself. For
the sake of extensions, we still need each
freeIntRepProc to do its own housekeeping as
well.
Yes, this is a gap in the interface. We ought to
have a public routine that plays this role.
Tcl sources updated. Tk still needs a look.
Thanks for getting the bits I missed in tclEncoding.c.
Just committed the other missed bits in tclVar.c.
Still open for Tk.
All fixed in Tk HEAD. Leaving to dgp to decide whether that means this item should be closed.