Tcl Source Code

View Ticket
Login
Ticket UUID: 1685436
Title: document Tcl_Preserve-ability
Type: RFE Created on: 2007-03-21 18:22:48
Submitter: dgp Assigned to: hobbs
Subsystem: 42. Memory Preservation Severity:
Priority: 5 Medium Last modified: 2007-04-03 21:07:05
Status: Open Closed by:
Resolution: None Closed on:
Version: None
Description:
Some public Tcl routines return
pointers that can be Tcl_Preserve()d;
for example, Tcl_CreateInterp().

Other public Tcl routines return
pointers that cannot be
Tcl_Preserve()d; for example,
Tcl_CreateNamespace().  The pointers
returned by such routines really
can't be reliably kept long-term.
Perhaps that's a bug, and more
return-able pointers need to support
Tcl_Preserve-ability.  If not, the
documentation should at least make
this distinction clear.
User Comments:
andreas_kupries added on 2007-03-22 04:10:58:
Logged In: YES 
user_id=75003
Originator: NO

I wonder if we can snarf ideas from the linux kernel for that. IIRC they are using special macros and type magic, likely gcc specific, to give pointers additional attributes which the compiler can check. For us basically a preserve-ability tag which goes with the pointer and is checker at compile time when Tcl_Preserve is used. I should note that I have no actual idea how their stuff works in detail. Regarding it being gcc specific, it should be easy to disable that for other compilers through redefinition of whatever macros are used to implement this.

Even if we are unable or unwilling to reproduce the thing we can still use macros like

    #define PRESERVABLE(x) x

to at least add appropriate tags in the sources. No compiler checks, but at least semi-documentation in the code.