[Asterisk-code-review] res stasis device state.c: Pull stack alloc out of loop. (asterisk[master])

Richard Mudgett asteriskteam at digium.com
Fri Nov 3 12:02:06 CDT 2017


Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/6977


Change subject: res_stasis_device_state.c: Pull stack alloc out of loop.
......................................................................

res_stasis_device_state.c: Pull stack alloc out of loop.

Change-Id: Ia27e64a884afa0f50b9ffdb1cf23da6bfa51ffdf
---
M res/res_stasis_device_state.c
1 file changed, 2 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/77/6977/1

diff --git a/res/res_stasis_device_state.c b/res/res_stasis_device_state.c
index 276a98b..41c12bc 100644
--- a/res/res_stasis_device_state.c
+++ b/res/res_stasis_device_state.c
@@ -171,11 +171,12 @@
 	RAII_VAR(struct ast_db_entry *, tree,
 		 ast_db_gettree(DEVICE_STATE_FAMILY, NULL), ast_db_freetree);
 	struct ast_db_entry *entry;
+	struct ast_str *device = ast_str_alloca(DEVICE_STATE_SIZE);
 
 	for (entry = tree; entry; entry = entry->next) {
 		const char *name = strrchr(entry->key, '/');
+
 		if (!ast_strlen_zero(name)) {
-			struct ast_str *device = ast_str_alloca(DEVICE_STATE_SIZE);
 			ast_str_set(&device, 0, "%s%s",
 				    DEVICE_STATE_SCHEME_STASIS, ++name);
 			ast_json_array_append(

-- 
To view, visit https://gerrit.asterisk.org/6977
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia27e64a884afa0f50b9ffdb1cf23da6bfa51ffdf
Gerrit-Change-Number: 6977
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171103/32169444/attachment.html>


More information about the asterisk-code-review mailing list