From 93706028de49438ac1e8a77f4a5993ceb3a5918c Mon Sep 17 00:00:00 2001 From: Alon Bar-Lev Date: Wed, 1 Nov 2023 21:05:25 +0200 Subject: [PATCH] change(console): drop the use of open_memstream() the argtable3 provides string based output return, there is no need to go via stdio structures. Signed-off-by: Alon Bar-Lev Signed-off-by: Ivan Grokhotkov Closes https://github.com/espressif/esp-idf/pull/12507 --- components/console/commands.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/components/console/commands.c b/components/console/commands.c index bdeef9b393..c5e1f2035f 100644 --- a/components/console/commands.c +++ b/components/console/commands.c @@ -125,14 +125,10 @@ esp_err_t esp_console_cmd_register(const esp_console_cmd_t *cmd) unused = asprintf(&item->hint, " %s", cmd->hint); } else if (cmd->argtable) { /* Generate hint based on cmd->argtable */ - char *buf = NULL; - size_t buf_size = 0; - FILE *f = open_memstream(&buf, &buf_size); - if (f != NULL) { - arg_print_syntax(f, cmd->argtable, NULL); - fclose(f); - } - item->hint = buf; + arg_dstr_t ds = arg_dstr_create(); + arg_print_syntax_ds(ds, cmd->argtable, NULL); + item->hint = strdup(arg_dstr_cstr(ds)); + arg_dstr_destroy(ds); } item->argtable = cmd->argtable;