diff options
author | Richard Mudgett <rmudgett@digium.com> | 2013-03-28 23:59:20 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2013-03-28 23:59:20 +0000 |
commit | a1c94fece82f2445e538de0c93345d34c4abdf17 (patch) | |
tree | 5e1f771efae1c221db8ecc3efaa4eb00632e19d8 /main/stasis.c | |
parent | 71206544a770eb4004294ed13613a7cde6e0e056 (diff) |
Add uuid wrapper API call ast_uuid_generate_str().
* Updated test_uuid.c to test the new API call.
* Made system use the new API call to eliminate "10's of lines" where
used.
* Fixed untested ast_strdup() return in stasis_subscribe() by eliminating
the need for it. struct stasis_subscription now contains the uniqueid[]
string.
* Fixed some issues in exchangecal_write_event():
Create uid with enough space for a UUID string to avoid a realloc.
Fix off by one error if the calendar event provided a UUID string.
There is no need to check for NULL before calling ast_free().
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@384302 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/stasis.c')
-rw-r--r-- | main/stasis.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/main/stasis.c b/main/stasis.c index d1baa442b..2bd432a0c 100644 --- a/main/stasis.c +++ b/main/stasis.c @@ -106,7 +106,7 @@ const char *stasis_topic_name(const struct stasis_topic *topic) /*! \internal */ struct stasis_subscription { /*! Unique ID for this subscription */ - char *uniqueid; + char uniqueid[AST_UUID_STR_LEN]; /*! Topic subscribed to. */ struct stasis_topic *topic; /*! Mailbox for processing incoming messages. */ @@ -121,8 +121,6 @@ static void subscription_dtor(void *obj) { struct stasis_subscription *sub = obj; ast_assert(!stasis_subscription_is_subscribed(sub)); - ast_free(sub->uniqueid); - sub->uniqueid = NULL; ao2_cleanup(sub->topic); sub->topic = NULL; ast_taskprocessor_unreference(sub->mailbox); @@ -134,27 +132,19 @@ static void send_subscription_change_message(struct stasis_topic *topic, char *u struct stasis_subscription *stasis_subscribe(struct stasis_topic *topic, stasis_subscription_cb callback, void *data) { RAII_VAR(struct stasis_subscription *, sub, NULL, ao2_cleanup); - RAII_VAR(struct ast_uuid *, id, NULL, ast_free); - char uniqueid[AST_UUID_STR_LEN]; sub = ao2_alloc(sizeof(*sub), subscription_dtor); if (!sub) { return NULL; } - id = ast_uuid_generate(); - if (!id) { - ast_log(LOG_ERROR, "UUID generation failed\n"); - return NULL; - } - ast_uuid_to_str(id, uniqueid, sizeof(uniqueid)); + ast_uuid_generate_str(sub->uniqueid, sizeof(sub->uniqueid)); - sub->mailbox = ast_threadpool_serializer(uniqueid, pool); + sub->mailbox = ast_threadpool_serializer(sub->uniqueid, pool); if (!sub->mailbox) { return NULL; } - sub->uniqueid = ast_strdup(uniqueid); ao2_ref(topic, +1); sub->topic = topic; sub->callback = callback; @@ -163,7 +153,7 @@ struct stasis_subscription *stasis_subscribe(struct stasis_topic *topic, stasis_ if (topic_add_subscription(topic, sub) != 0) { return NULL; } - send_subscription_change_message(topic, uniqueid, "Subscribe"); + send_subscription_change_message(topic, sub->uniqueid, "Subscribe"); ao2_ref(sub, +1); return sub; |