diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-06-06 21:59:57 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-06-06 21:59:57 (GMT) |
commit | 062bd7ee8f8c36ffa3d231e2fc8ebf6231115b6a (patch) | |
tree | a0d0b655ae19f00511726f63f3629ee40d98ef1e /generic/tclTrace.c | |
parent | cacfaf16ecf05b44bacecbba3b2f673bf810e64c (diff) | |
parent | 345e120ec855d9f7d33f9715a2eecbceac2fafd2 (diff) | |
download | tcl-062bd7ee8f8c36ffa3d231e2fc8ebf6231115b6a.zip tcl-062bd7ee8f8c36ffa3d231e2fc8ebf6231115b6a.tar.gz tcl-062bd7ee8f8c36ffa3d231e2fc8ebf6231115b6a.tar.bz2 |
Merge 8.7
Diffstat (limited to 'generic/tclTrace.c')
-rw-r--r-- | generic/tclTrace.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/generic/tclTrace.c b/generic/tclTrace.c index d84e183..f85ee4d 100644 --- a/generic/tclTrace.c +++ b/generic/tclTrace.c @@ -2125,9 +2125,9 @@ typedef struct { Tcl_CmdObjTraceProc2 *proc; Tcl_CmdObjTraceDeleteProc *delProc; void *clientData; -} TraceWrapper; +} TraceWrapperInfo; -static int wrapperProc2( +static int traceWrapperProc( void *clientData, Tcl_Interp *interp, int level, @@ -2136,16 +2136,18 @@ static int wrapperProc2( int objc, struct Tcl_Obj *const objv[]) { - TraceWrapper *wrapper = (TraceWrapper *)clientData; - return wrapper->proc(wrapper->clientData, interp, level, command, commandInfo, objc, objv); + TraceWrapperInfo *info = (TraceWrapperInfo *)clientData; + return info->proc(info->clientData, interp, level, command, commandInfo, objc, objv); } -static void wrapperDelProc2(void *clientData) +static void traceWrapperDelProc(void *clientData) { - TraceWrapper *wrapper = (TraceWrapper *)clientData; - clientData = wrapper->clientData; - wrapper->delProc(clientData); - Tcl_Free(wrapper); + TraceWrapperInfo *info = (TraceWrapperInfo *)clientData; + clientData = info->clientData; + if (info->delProc) { + info->delProc(clientData); + } + ckfree(info); } Tcl_Trace @@ -2158,11 +2160,13 @@ Tcl_CreateObjTrace2( Tcl_CmdObjTraceDeleteProc *delProc) /* Function to call when trace is deleted */ { - TraceWrapper *wrapper = (TraceWrapper *)Tcl_Alloc(sizeof(TraceWrapper)); - wrapper->proc = proc; - wrapper->delProc = delProc; - wrapper->clientData = clientData; - return Tcl_CreateObjTrace(interp, level, flags, wrapperProc2, wrapper, wrapperDelProc2); + TraceWrapperInfo *info = (TraceWrapperInfo *)ckalloc(sizeof(TraceWrapperInfo)); + info->proc = proc; + info->delProc = delProc; + info->clientData = clientData; + return Tcl_CreateObjTrace(interp, level, flags, + (proc ? traceWrapperProc : NULL), + info, traceWrapperDelProc); } Tcl_Trace |