From 8aba2b3e6f8658bf80dd42684f17e00e99acc0a2 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 1 Aug 2024 14:18:43 -0400 Subject: [PATCH] MT#55283 add *list_add_str_dup method Change-Id: Ic6dac373f9fb16a83e20d12ff7f05d272633e859 --- daemon/call_interfaces.c | 6 +++--- daemon/control_ng.c | 2 ++ include/control_ng.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 26fe6e7fd..299a060c5 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -2742,7 +2742,7 @@ stats: } } -static void ng_list_calls(bencode_item_t *output, long long int limit) { +static void ng_list_calls(ng_parser_ctx_t *ctx, bencode_item_t *output, long long int limit) { rtpe_calls_ht_iter iter; rwlock_lock_r(&rtpe_callhash_lock); @@ -2750,7 +2750,7 @@ static void ng_list_calls(bencode_item_t *output, long long int limit) { t_hash_table_iter_init (&iter, rtpe_callhash); str *key; while (limit-- && t_hash_table_iter_next (&iter, &key, NULL)) { - bencode_list_add_str_dup(output, key); + ctx->parser->list_add_str_dup(output, key); } rwlock_unlock_r(&rtpe_callhash_lock); @@ -2792,7 +2792,7 @@ const char *call_list_ng(ng_parser_ctx_t *ctx) { } calls = ctx->parser->dict_add_list(output, "calls"); - ng_list_calls(calls, limit); + ng_list_calls(ctx, calls, limit); return NULL; } diff --git a/daemon/control_ng.c b/daemon/control_ng.c index 1d8b656fc..adbc09d41 100644 --- a/daemon/control_ng.c +++ b/daemon/control_ng.c @@ -346,6 +346,7 @@ const ng_parser_t ng_parser_native = { .list_add = bencode_list_add, .list_add_dict = bencode_list_add_dictionary, .list_add_string = bencode_list_add_string, + .list_add_str_dup = bencode_list_add_str_dup, .pretty_print = bencode_pretty_print, }; const ng_parser_t ng_parser_json = { @@ -375,6 +376,7 @@ const ng_parser_t ng_parser_json = { .list_add = bencode_list_add, .list_add_dict = bencode_list_add_dictionary, .list_add_string = bencode_list_add_string, + .list_add_str_dup = bencode_list_add_str_dup, .pretty_print = json_pretty_print, }; diff --git a/include/control_ng.h b/include/control_ng.h index da353cf7e..c08932bc8 100644 --- a/include/control_ng.h +++ b/include/control_ng.h @@ -144,6 +144,7 @@ struct ng_parser { parser_arg (*list)(ng_parser_ctx_t *); bencode_item_t *(*list_add)(parser_arg, parser_arg); bencode_item_t *(*list_add_dict)(bencode_item_t *); + void (*list_add_str_dup)(parser_arg, const str *); void (*list_add_string)(bencode_item_t *, const char *); void (*pretty_print)(parser_arg, GString *); };