From 1660933d76b335048b7e9b3085d3e64f7af7b338 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Fri, 13 Nov 2026 20:27:47 +0000 Subject: replace by malloc(), cleanup attribute, and removed unused .h --- src/eval/eval_exe.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/eval') diff --git a/src/eval/eval_exe.cc b/src/eval/eval_exe.cc index 65e5a34..009fc1c 100644 --- a/src/eval/eval_exe.cc +++ b/src/eval/eval_exe.cc @@ -12,6 +12,7 @@ #include "lang_analysis/symbol_property.h" #include "lang_analysis/parseline.h" #include "util/io.h" +#include "memory.h" using namespace std; @@ -34,7 +35,7 @@ int eval_exe(const string &s, bool is_async, const T_lexer *lexer_instance, size bool task_type_is_subshell = false; const char *raw_input = nullptr; - char **argv = nullptr; + __attribute__((cleanup(cleanup_free_argv))) char **argv = nullptr; const char *unified_cmd_c = nullptr; string unified_cmd, s_wrap_eliminated; @@ -55,9 +56,13 @@ int eval_exe(const string &s, bool is_async, const T_lexer *lexer_instance, size // NB: remember to delete argv = parseline(s); - if (argv == nullptr || argv[0] == nullptr) { operator delete(argv); return 0; } - if (exe_bultin_command(argv)) { operator delete(argv); return 0; } + // the compiler should free() it here + // if returns + + if (argv == nullptr || argv[0] == nullptr) { return 0; } + + if (exe_bultin_command(argv)) { return 0; } unified_cmd = find_cmd(argv[0]); unified_cmd_c = unified_cmd.c_str(); @@ -102,8 +107,7 @@ int eval_exe(const string &s, bool is_async, const T_lexer *lexer_instance, size } // parent - - operator delete(argv); + free(argv); argv = nullptr; exit_required_pid = pid; @@ -136,4 +140,4 @@ int eval_exe(const string &s, bool is_async, const T_lexer *lexer_instance, size return 0; } -} \ No newline at end of file +} -- cgit v1.3.1-4-g156e