Updated 2010-10-20 09:27:44 by dkf

For C code that calls Tcl public routines that accept (Tcl_Obj *) arguments, the most efficient techniques for reference count management rely on knowing which routines are known safe to pass a zero-ref Tcl_Obj to.

These are the routines that do not make any call to Tcl_DecrRefCount() on the argument, and do not call anything else that does. Here's the start of a list. Please add to it:

MJ thinks a list like this is a dangerous thing. Safest thing is to do an [Tcl_IncrRefCount] at the beginning and a [Tcl_DecrRefCount] at the end. There are several reasons why I think this is better:

  • The performance penalty is negligible
  • It always works even if the routine does do a [Tcl_DecrRefCount] so there is no need to keep referring to this list
  • It will work in other versions of Tcl where the functions in this list may have been changed so they do manipulate the refcount