Overview
| Artifact ID: | 31723752f4d0776157ee528f32b0d15c245cba89 |
|---|---|
| Ticket: | 405998ffffffffffffffffffffffffffffffffff
Tcl_SetListObj fails reset obj properly |
| User & Date: | hobbs on 2001-03-30 01:58:05 |
Changes
- assignee changed to: "dgp"
- icomment:
Logged In: YES user_id=72656 OK, it looks like there are a few things here that could be fixed. There is a bug, but I think that setting length to 0 is just a band-aid. In SetStringFromAny, the reason it uses the objPtr->length is that bytes != NULL, WITHOUT checking for bytes == tclEmptyStringRep (a pseudo- equivalent) which other procs in tclStringObj.c make sure to do (also in tclObj.c). So, you could fix SetStringFromAny to account for this just as Tcl_SetObjLength and others do. However, what might be more interesting, and has come up in discussion before, is why an empty list isn't a Tcl list obj. The following is not true: Tcl_SetListObj(objPtr, objc, objv); /* This fails for objc == 0 */ assert(objPtr->type == &tclListType); From basic tests, you wouldn't save much time trying to avoid that, because any tclListType must have a valid list rep (which means an alloc for an empty list). It seems odd in any case that Tcl_SetListObj would just set the bytes to tclEmptyStringRep when that means anything done to the object will cause it to become a string. All in all, it might be easiest to set the length to 0, and note that that is equivalent to TclInitStringRep. It looks to be intentional (and in the spirit of Tcl) that empty objects have no particular type to start, and don't get one until you do something with it.
- login: "hobbs"
- mimetype: "text/plain"
- username: "hobbs"