Overview
| Artifact ID: | c2aa33b13690b581658364cf23ad1f3b3cb2400c |
|---|---|
| Ticket: | 756883ffffffffffffffffffffffffffffffffff
ResetObjResult to call registered free function first time |
| User & Date: | ysutjandra on 2003-06-18 22:24:41 |
Changes
- assignee changed to: "msofer"
- cmimetype changed to: "text/plain"
- comment changed to:
Hi, In tclResult.c inside function ResetObjResult(iPtr) Would you consider instead of... if (Tcl_IsShared(objResultPtr)) { ... } else { if ((objResultPtr->bytes != NULL) && (objResultPtr->bytes != tclEmptyStringRep)) { ckfree((char *) objResultPtr->bytes); } objResultPtr->bytes = tclEmptyStringRep; objResultPtr->length = 0; if ((objResultPtr->typePtr != NULL) && (objResultPtr->typePtr->freeIntRepProc ! = NULL)) { objResultPtr->typePtr->freeIntRepProc (objResultPtr); } objResultPtr->typePtr = (Tcl_ObjType *) NULL; } consider... if (Tcl_IsShared(objResultPtr)) { ... } else { TclDecrRefCount(objResultPtr); /* This automatically calls the free function if result object holds its own internal representation. And depending on the free function of the registered type It might already invalidate the 'bytes' field of the Tcl_Obj and set the 'bytes' to NULL and the 'length' to zero. */ if ((objResultPtr->bytes != NULL) && (objResultPtr->bytes != tclEmptyStringRep)) { ckfree((char *) objResultPtr->bytes); } objResultPtr->bytes = tclEmptyStringRep; objResultPtr->length = 0; objResultPtr->typePtr = (Tcl_ObjType *) NULL; Tcl_IncrRefCount(objResultPtr); } I'm not sure if it's a bug, but with the current implementation, the registered free function is called when refCount is still one. Moreover, if the result object holds its internal representation, the bytes field may hold ths string that is obtained from calling Tcl_UpdateStringObj, which calls the registered UpdateStringProc. The software client is free to use its own memory allocator when updating the bytes string. So I think it's a bug to assume that the bytes is allocated using ckalloc. -- Yohan - foundin changed to: "None"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "ysutjandra"
- subsystem changed to: "10. Objects"
- title changed to:
ResetObjResult to call registered free function first time
- type changed to: "RFE"