diff options
| author | _ov4 <ov4@ov4.org> | 2026-11-13 20:27:47 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-11-13 20:27:47 +0000 |
| commit | 1660933d76b335048b7e9b3085d3e64f7af7b338 (patch) | |
| tree | d389918a84bb176bec5313b586642be2b61f2b3a /src/eval/eval_exe.cc | |
| parent | 111272567f63e4e5faf5a8e5b518c4e68d9d96bf (diff) | |
replace by malloc(), cleanup attribute, and removed unused .h
Diffstat (limited to 'src/eval/eval_exe.cc')
| -rw-r--r-- | src/eval/eval_exe.cc | 16 |
1 files changed, 10 insertions, 6 deletions
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 +} |
