From b2ab2241f20fd3da11c92f8edde4639ab8ce996f Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Mon, 12 Apr 2021 00:04:19 +0200 Subject: [PATCH] jimtcl: revert temporary workaround for memory leak in jimtcl 0.80 By using jimtcl from latest master branch, the workaround added in commit 36ae487ed04b ("jimtcl: add temporary workaround for memory leak in jimtcl 0.80") is not needed anymore. Revert the workaround. Change-Id: Ia1b5804be15362d0400740c375455ee19ac09f04 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/6228 Tested-by: jenkins Reviewed-by: Oleksij Rempel --- src/helper/command.c | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/src/helper/command.c b/src/helper/command.c index 7c29f73e6e..53ee2508a9 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -137,41 +137,6 @@ static void command_log_capture_finish(struct log_capture_state *state) free(state); } -/* - * FIXME: workaround for memory leak in jimtcl 0.80 - * Jim API Jim_CreateCommand() converts the command name in a Jim object and - * does not free the object. Fixed for jimtcl 0.81 by e4416cf86f0b - * Use the internal jimtcl API Jim_CreateCommandObj, not exported by jim.h, - * and override the bugged API through preprocessor's macro. - * This workaround works only when jimtcl is compiled as OpenOCD submodule. - * It's broken on macOS, so it's currently restricted on Linux only. - * If jimtcl is linked-in from a precompiled library, either static or dynamic, - * the symbol Jim_CreateCommandObj is not exported and the build will use the - * bugged API. - * To be removed when OpenOCD will switch to jimtcl 0.81 - */ -#if JIM_VERSION == 80 && defined __linux__ -static int workaround_createcommand(Jim_Interp *interp, const char *cmdName, - Jim_CmdProc *cmdProc, void *privData, Jim_DelCmdProc *delProc); -int Jim_CreateCommandObj(Jim_Interp *interp, Jim_Obj *cmdNameObj, - Jim_CmdProc *cmdProc, void *privData, Jim_DelCmdProc *delProc) -__attribute__((weak, alias("workaround_createcommand"))); -static int workaround_createcommand(Jim_Interp *interp, const char *cmdName, - Jim_CmdProc *cmdProc, void *privData, Jim_DelCmdProc *delProc) -{ - if ((void *)Jim_CreateCommandObj == (void *)workaround_createcommand) - return Jim_CreateCommand(interp, cmdName, cmdProc, privData, delProc); - - Jim_Obj *cmd_name = Jim_NewStringObj(interp, cmdName, -1); - Jim_IncrRefCount(cmd_name); - int retval = Jim_CreateCommandObj(interp, cmd_name, cmdProc, privData, delProc); - Jim_DecrRefCount(interp, cmd_name); - return retval; -} -#define Jim_CreateCommand workaround_createcommand -#endif /* JIM_VERSION == 80 && defined __linux__*/ -/* FIXME: end of workaround for memory leak in jimtcl 0.80 */ - static int command_retval_set(Jim_Interp *interp, int retval) { int *return_retval = Jim_GetAssocData(interp, "retval"); -- 2.30.2