[Asterisk-code-review] stasis: Remove stringfields and lock from change message. (asterisk[13])

Jenkins2 asteriskteam at digium.com
Tue Nov 20 05:05:30 CST 2018


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/10691 )

Change subject: stasis: Remove stringfields and lock from change message.
......................................................................

stasis: Remove stringfields and lock from change message.

When a subscribe or unsubscribe occurs a message is published
containing this information. This change makes it so that the
message no longer uses stringfields or a lock, as both are not
really needed for the message.

Change-Id: I3f4831931d79f94fd979baf48048738df5dc1632
---
M include/asterisk/stasis.h
M main/stasis.c
2 files changed, 10 insertions(+), 11 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Corey Farrell: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/include/asterisk/stasis.h b/include/asterisk/stasis.h
index a9d5a74..dd9583e 100644
--- a/include/asterisk/stasis.h
+++ b/include/asterisk/stasis.h
@@ -816,11 +816,9 @@
  * \since 12
  */
 struct stasis_subscription_change {
-	AST_DECLARE_STRING_FIELDS(
-		AST_STRING_FIELD(uniqueid);	/*!< The unique ID associated with this subscription */
-		AST_STRING_FIELD(description);	/*!< The description of the change to the subscription associated with the uniqueid */
-	);
-	struct stasis_topic *topic;		/*!< The topic the subscription is/was subscribing to */
+	struct stasis_topic *topic; /*!< The topic the subscription is/was subscribing to */
+	char *uniqueid;             /*!< The unique ID associated with this subscription */
+	char description[0];        /*!< The description of the change to the subscription associated with the uniqueid */
 };
 
 /*!
diff --git a/main/stasis.c b/main/stasis.c
index d054897..17055d8 100644
--- a/main/stasis.c
+++ b/main/stasis.c
@@ -1079,22 +1079,23 @@
 {
 	struct stasis_subscription_change *change = obj;
 
-	ast_string_field_free_memory(change);
 	ao2_cleanup(change->topic);
 }
 
 static struct stasis_subscription_change *subscription_change_alloc(struct stasis_topic *topic, const char *uniqueid, const char *description)
 {
+	size_t description_len = strlen(description) + 1;
 	struct stasis_subscription_change *change;
 
-	change = ao2_alloc(sizeof(struct stasis_subscription_change), subscription_change_dtor);
-	if (!change || ast_string_field_init(change, 128)) {
-		ao2_cleanup(change);
+	change = ao2_alloc_options(sizeof(*change) + description_len + strlen(uniqueid) + 1,
+		subscription_change_dtor, AO2_ALLOC_OPT_LOCK_NOLOCK);
+	if (!change) {
 		return NULL;
 	}
 
-	ast_string_field_set(change, uniqueid, uniqueid);
-	ast_string_field_set(change, description, description);
+	strcpy(change->description, description); /* SAFE */
+	change->uniqueid = change->description + description_len;
+	strcpy(change->uniqueid, uniqueid); /* SAFE */
 	ao2_ref(topic, +1);
 	change->topic = topic;
 

-- 
To view, visit https://gerrit.asterisk.org/10691
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I3f4831931d79f94fd979baf48048738df5dc1632
Gerrit-Change-Number: 10691
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2 (1000185)
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181120/9a0dc2a6/attachment.html>


More information about the asterisk-code-review mailing list