Tcl_GetAssocData, Tcl_SetAssocData, Tcl_DeleteAssocData -
manage associations of string keys and user specified data
with Tcl interpreters.
Tcl_GetAssocData(interp, key, delProcPtr)
Tcl_SetAssocData(interp, key, delProc, clientData)
Tcl_Interp *interp (in) Interpreter
in which to
char *key (in) Key for
fix for a
Tcl_InterpDeleteProc *delProc (in) Procedure
Tcl_InterpDeleteProc **delProcPtr (in) Pointer to
ClientData clientData (in) Arbitrary
key in this
is owned by
These procedures allow extensions to associate their own
data with a Tcl interpreter. An association consists of a
string key, typically the name of the extension, and a
one-word value, which is typically a pointer to a data
structure holding data specific to the extension. Tcl
makes no interpretation of either the key or the value for
Storage management is facilitated by storing with each
association a procedure to call when the interpreter is
deleted. This procedure can dispose of the storage occu
pied by the client's data in any way it sees fit.
Tcl_SetAssocData creates an association between a string
key and a user specified datum in the given interpreter.
If there is already an association with the given key,
Tcl_SetAssocData overwrites it with the new information.
It is up to callers to organize their use of names to
avoid conflicts, for example, by using package names as
the keys. If the deleteProc argument is non-NULL it spec
ifies the address of a procedure to invoke if the inter
preter is deleted before the association is deleted.
DeleteProc should have arguments and result that match the
typedef void Tcl_InterpDeleteProc(
When deleteProc is invoked the clientData and interp argu
ments will be the same as the corresponding arguments
passed to Tcl_SetAssocData. The deletion procedure will
not be invoked if the association is deleted before the
interpreter is deleted.
Tcl_GetAssocData returns the datum stored in the associa
tion with the specified key in the given interpreter, and
if the delProcPtr field is non-NULL, the address indicated
exists in the given interpreter Tcl_GetAssocData returns
Tcl_DeleteAssocData deletes an association with a speci
fied key in the given interpreter. Then it calls the
association, data, deletion procedure, interpreter, key