So....
1) What is the difference between Tcl_Free and ckfree?
2) Why doesn't it show up in tcl executables?
Ok. Tcl 8.0, w/ TclX, Linux Platform. Module is tnm, from scotty, with
some stuff I've added (which uses Tcl_Free).
-- cary
Look in the tcl.h and you'll see. Tcl uses the ck* functions on Unix,
but not Mac/Win (wasn't it pointed out that Tcl picked up a faster
mem allocator for the Mac than the compiler provided one?).
In general, it is important to use them on non-Unix platforms, or when
using Tcl with mem debugging. The man page gives the reasons why.
** Jeffrey Hobbs jeff.hobbs @SPAM acm.org **
** I'm really just a Tcl-bot My opinions are MY opinions **
I always use Tcl_Free, Tcl_Alloc and Tcl_Realloc, the main reason is
that if I need to turn on memory debugging I do not need to rebuild all
of my extensions because internally Tcl redirects them to the memory
debug versions. This means that it is easier to debug memory leaks and
corruption.
Another reason is that I think that Tcl should provide a nice error
message if an application runs out of memory instead of crashing in
some place in the code. One way to do this is for everyone to call
Tcl_Alloc and have that check whether any memory was allocated and if
not it could panic.
--
Paul Duffin
DT/6000 Development Email: pdu...@hursley.ibm.com
IBM UK Laboratories Ltd., Hursley Park nr. Winchester
Internal: 7-246880 International: +44 1962-816880
Ok, so if I use Tcl_Free, I've got a compilation problem. Well, a
linking problem. If I build tcl (i.e. stock tcl + tclx) there is *no*
Tcl_Free() function in the base interpreter. Honest. Checked with
nm.
If I build a loadable module that calls Tcl_Free(), when I load it I
get an error message saying 'can't find Tcl_Free()'. I could add
-ltcl to the end of the link that makes the shared library, but
then it is huge.
I looked through the tcl and tclX source and didn't see Tcl_Free() anywhere
except in the *.h file.
Any ideas?
-- cary
As you are building a standalone version I would assume that because Tcl
does not use any of the functions from the tclCkalloc object file it is
not included in the executable. The solution is to change one of the
uses of ckalloc to Tcl_Alloc.
BTW
What version of Tcl are you using ?
Are you using Tcl's Stub mechanism ?