This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Vadim Yanitskiy gerrit-no-reply at lists.osmocom.orgVadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/13534 Change subject: vty/talloc_ctx_vty.c: allocate walk_cb_params on stack, not heap ...................................................................... vty/talloc_ctx_vty.c: allocate walk_cb_params on stack, not heap There is no need to allocate struct 'walk_cb_params' dynamically. Change-Id: I96f25f1ddb36b19b12055deaeeb6f58e59180e72 --- M src/vty/talloc_ctx_vty.c 1 file changed, 15 insertions(+), 43 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/34/13534/1 diff --git a/src/vty/talloc_ctx_vty.c b/src/vty/talloc_ctx_vty.c index e7fe675..c4d5a88 100644 --- a/src/vty/talloc_ctx_vty.c +++ b/src/vty/talloc_ctx_vty.c @@ -180,22 +180,13 @@ DEFUN(show_talloc_ctx, show_talloc_ctx_cmd, BASE_CMD_STR, BASE_CMD_DESCR) { - struct walk_cb_params *params; - - /* Allocate memory */ - params = talloc_zero(tall_vty_ctx, struct walk_cb_params); - if (!params) - return CMD_WARNING; + struct walk_cb_params params = { 0 }; /* Set up callback parameters */ - params->filter = WALK_FILTER_NONE; - params->vty = vty; + params.filter = WALK_FILTER_NONE; + params.vty = vty; - talloc_ctx_walk(argv[0], argv[1], params); - - /* Free memory */ - talloc_free(params); - + talloc_ctx_walk(argv[0], argv[1], ¶ms); return CMD_SUCCESS; } @@ -204,31 +195,22 @@ "Filter chunks using regular expression\n" "Regular expression\n") { - struct walk_cb_params *params; + struct walk_cb_params params = { 0 }; int rc; - /* Allocate memory */ - params = talloc_zero(tall_vty_ctx, struct walk_cb_params); - if (!params) - return CMD_WARNING; - /* Attempt to compile a regular expression */ - rc = regcomp(¶ms->regexp, argv[2], 0); + rc = regcomp(¶ms.regexp, argv[2], 0); if (rc) { vty_out(vty, "Invalid expression%s", VTY_NEWLINE); - talloc_free(params); return CMD_WARNING; } /* Set up callback parameters */ - params->filter = WALK_FILTER_REGEXP; - params->vty = vty; + params.filter = WALK_FILTER_REGEXP; + params.vty = vty; - talloc_ctx_walk(argv[0], argv[1], params); - - /* Free memory */ - regfree(¶ms->regexp); - talloc_free(params); + talloc_ctx_walk(argv[0], argv[1], ¶ms); + regfree(¶ms.regexp); return CMD_SUCCESS; } @@ -238,31 +220,21 @@ "Display only a specific memory chunk\n" "Chunk address (e.g. 0xdeadbeef)\n") { - struct walk_cb_params *params; + struct walk_cb_params params = { 0 }; int rc; - /* Allocate memory */ - params = talloc_zero(tall_vty_ctx, struct walk_cb_params); - if (!params) - return CMD_WARNING; - /* Attempt to parse an address */ - rc = sscanf(argv[2], "%p", ¶ms->chunk_ptr); + rc = sscanf(argv[2], "%p", ¶ms.chunk_ptr); if (rc != 1) { vty_out(vty, "Invalid chunk address%s", VTY_NEWLINE); - talloc_free(params); return CMD_WARNING; } /* Set up callback parameters */ - params->filter = WALK_FILTER_TREE; - params->vty = vty; + params.filter = WALK_FILTER_TREE; + params.vty = vty; - talloc_ctx_walk(argv[0], argv[1], params); - - /* Free memory */ - talloc_free(params); - + talloc_ctx_walk(argv[0], argv[1], ¶ms); return CMD_SUCCESS; } -- To view, visit https://gerrit.osmocom.org/13534 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: I96f25f1ddb36b19b12055deaeeb6f58e59180e72 Gerrit-Change-Number: 13534 Gerrit-PatchSet: 1 Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190406/d910f128/attachment.htm>