Home
DevCentral
Search
Configure Global Search
Log In
Transactions
T1006
Change Details
Change Details
Old
New
Diff
@xcombelle noticed `malloc` calls wasn't followed by `free` in the library source code. At writing time, this probably occured: - static strings was passed to the TCL interpreter - they was rightly declared as static - compiler complained a const string doesn't match Tcl_Setresult char* signature - code switched to char* - code doesn't make anymore any warranty of immutability, but advertise so to TCL >>! https://www.tcl.tk/man/tcl/TclLib/Interp.htm says (seems to be for TCL_STATIC): > Normally, results are assumed to be statically allocated, which means that the contents will not change before the next time Tcl_Eval is called or some other command procedure is invoked. In this case, the freeProc field must be zero." >>! http://tmml.sourceforge.net/doc/tcl/SetResult.html says: > Tcl_ResetResult clears the result for interp, freeing the memory associated with it if the current result was dynamically allocated. It leaves the result in its normal initialized state with interp->result pointing to a static buffer containing TCL_RESULT_SIZE characters, of which the first character is zero. Tcl_ResetResult also clears the error state managed by Tcl_AddErrorInfo and Tcl_SetErrorCode. > Tcl_FreeResult is a macro that performs part of the work of Tcl_ResetResult. It frees up the memory associated with interp's result and sets interp->freeProc to zero, but it doesn't change interp->result or clear error state. Tcl_FreeResult is most commonly used when a procedure is about to replace one result value with another. This [[ https://groups.google.com/forum/#!topic/comp.lang.tcl/DUbn5yT3RsI | comp.lang.tcl post ]] by Adrian Ho explains very well the difference between TCL_STATIC and TCL_DYNAMIC in term of promises done by the library code to the TCL interpreter. It seems if we only want to free the pointer, the macro TCL_DYNAMIC could be use. If we need more complex behavior, a callback should be provided.
@xcombelle noticed `malloc` calls wasn't followed by `free` in the library source code. At writing time, this probably occured: - static strings was passed to the TCL interpreter - they was rightly declared as static - compiler complained a const string doesn't match Tcl_Setresult char* signature - code switched to char* - code doesn't make anymore any warranty of immutability, but advertise so to TCL >>! https://www.tcl.tk/man/tcl/TclLib/Interp.htm says (seems to be for TCL_STATIC): > Normally, results are assumed to be statically allocated, which means that the contents will not change before the next time Tcl_Eval is called or some other command procedure is invoked. In this case, the freeProc field must be zero." >>! http://tmml.sourceforge.net/doc/tcl/SetResult.html says: > Tcl_ResetResult clears the result for interp, freeing the memory associated with it if the current result was dynamically allocated. It leaves the result in its normal initialized state with interp->result pointing to a static buffer containing TCL_RESULT_SIZE characters, of which the first character is zero. Tcl_ResetResult also clears the error state managed by Tcl_AddErrorInfo and Tcl_SetErrorCode. > Tcl_FreeResult is a macro that performs part of the work of Tcl_ResetResult. It frees up the memory associated with interp's result and sets interp->freeProc to zero, but it doesn't change interp->result or clear error state. Tcl_FreeResult is most commonly used when a procedure is about to replace one result value with another. This [[ https://groups.google.com/forum/#!topic/comp.lang.tcl/DUbn5yT3RsI | comp.lang.tcl post ]] by Adrian Ho explains very well the difference between TCL_STATIC and TCL_DYNAMIC in term of promises done by the library code to the TCL interpreter. It seems if we only want to free the pointer, the macro TCL_DYNAMIC could be use. If we need more complex behavior, a callback should be provided. **Relevant files repository:** rRABBITMQTCL
@xcombelle noticed `malloc` calls wasn't followed by `free` in the library source code. At writing time, this probably occured: - static strings was passed to the TCL interpreter - they was rightly declared as static - compiler complained a const string doesn't match Tcl_Setresult char* signature - code switched to char* - code doesn't make anymore any warranty of immutability, but advertise so to TCL >>! https://www.tcl.tk/man/tcl/TclLib/Interp.htm says (seems to be for TCL_STATIC): > Normally, results are assumed to be statically allocated, which means that the contents will not change before the next time Tcl_Eval is called or some other command procedure is invoked. In this case, the freeProc field must be zero." >>! http://tmml.sourceforge.net/doc/tcl/SetResult.html says: > Tcl_ResetResult clears the result for interp, freeing the memory associated with it if the current result was dynamically allocated. It leaves the result in its normal initialized state with interp->result pointing to a static buffer containing TCL_RESULT_SIZE characters, of which the first character is zero. Tcl_ResetResult also clears the error state managed by Tcl_AddErrorInfo and Tcl_SetErrorCode. > Tcl_FreeResult is a macro that performs part of the work of Tcl_ResetResult. It frees up the memory associated with interp's result and sets interp->freeProc to zero, but it doesn't change interp->result or clear error state. Tcl_FreeResult is most commonly used when a procedure is about to replace one result value with another. This [[ https://groups.google.com/forum/#!topic/comp.lang.tcl/DUbn5yT3RsI | comp.lang.tcl post ]] by Adrian Ho explains very well the difference between TCL_STATIC and TCL_DYNAMIC in term of promises done by the library code to the TCL interpreter. It seems if we only want to free the pointer, the macro TCL_DYNAMIC could be use. If we need more complex behavior, a callback should be provided.
**Relevant files repository:** rRABBITMQTCL
Continue