Overview
| Artifact ID: | d22aa6b54780e343989c1095e5e05c1109f2f92a |
|---|---|
| Ticket: | 1998273fffffffffffffffffffffffffffffffff
Making a proc arg's unshared |
| User & Date: | ferrieux on 2008-06-19 21:55:13 |
Changes
- assignee changed to: "msofer"
- cmimetype changed to: "text/plain"
- comment changed to:
Inside a proc, a value passed as argument typically has a refcount of three. Of the two unwanted ones, one is easily removed: the local var foo $x[unset x] but the other is harder: it is in the CallFrame's objv, basically [info level 0]. The attached patch provides [info zaplevel] which prematurely neutralizes the [info level 0] data for that purpose. Thus, in proc pop x { info zaplevel lrange $x[unset x] 0 end-1 } The $x value is effectively passed unshared, provided it is passed unshared by the caller. The patch works by downing the refcounts of all members of [info level 0] except the head (to keep the proc name visible, should someone call [info level 0] after [info zaplevel]), and replacing them with references to a shared empty Tcl_Obj. Hence an [info level 0] of "foo a b c" becomes "foo {} {} {}". This gives us safety in the event of callers cacheing CallFrame->objc,objv in locals/registers. - foundin changed to: "None"
- is_private changed to: "0"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "ferrieux"
- subsystem changed to: "10. Objects"
- title changed to: "Making a proc arg's unshared"
- type changed to: "RFE"