[GRASS5] NVIZ and threaded TCL 8.4 working
cedricgrass at shockfamily.net
Tue Mar 14 21:03:47 EST 2006
The subject is indeed correct:
My tcl and tk 8.4 binaries are Ubuntu, which are probably pretty similar to
Many of the nviz c source files call Tcl_Merge to make return strings, and
assign them to interp->result where interp is the TCL interpreter like this:
interp->result = Tcl_Merge(3, list);
Then they set the freeProc ("function" to call to free the memory) to be free
(glibc). Tcl_Merge allocates its memory with Tcl_Alloc, not with malloc.
Before 8.4 Tcl_Alloc just happened to be malloc, but it's not anymore. The
correct thing to do is to set the freeProc to be TCL_DYNAMIC, which will be
TCL's opposite of Tcl_Alloc, like this:
interp->freeProc = TCL_DYNAMIC;
I replaced all of the references to glibc free as freeProc (only related to
results that use Tcl_Alloc, which turns out to be all of them) with
TCL_DYNAMIC. I also found one case of sprintf-ing to interp->result without
allocating memory and replaced it with the appropriate (Tcl_SetResult?) code.
I am not including a patch, as the number of differences between my current
codebase and CVS is ridiculous to try to deal with by editing cvs diff -u -p
patch files by hand.
More information about the grass-dev