summaryrefslogtreecommitdiff
path: root/main/stasis_cache.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2014-03-01 00:02:02 +0000
committerRichard Mudgett <rmudgett@digium.com>2014-03-01 00:02:02 +0000
commit77625956dd13cd95ac3d677b34562b423ed91e4a (patch)
tree4ee4d996cdbaba129a44ae555ee1d0f27327550a /main/stasis_cache.c
parentf9c031ec3986f40c216b11206ff02c96cfd1d1b7 (diff)
stasis_cache.c: Remove some unnecessary RAII_VAR() usage.
........ Merged revisions 409272 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@409273 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/stasis_cache.c')
-rw-r--r--main/stasis_cache.c59
1 files changed, 26 insertions, 33 deletions
diff --git a/main/stasis_cache.c b/main/stasis_cache.c
index 86d4f4d21..1c5053915 100644
--- a/main/stasis_cache.c
+++ b/main/stasis_cache.c
@@ -57,7 +57,8 @@ struct stasis_caching_topic {
struct stasis_subscription *sub;
};
-static void stasis_caching_topic_dtor(void *obj) {
+static void stasis_caching_topic_dtor(void *obj)
+{
struct stasis_caching_topic *caching_topic = obj;
/* Caching topics contain subscriptions, and must be manually
@@ -84,26 +85,28 @@ struct stasis_topic *stasis_caching_get_topic(struct stasis_caching_topic *cachi
struct stasis_caching_topic *stasis_caching_unsubscribe(struct stasis_caching_topic *caching_topic)
{
- if (caching_topic) {
- RAII_VAR(struct stasis_caching_topic *, hold_ref, NULL,
- ao2_cleanup);
+ if (!caching_topic) {
+ return NULL;
+ }
- /* The subscription may hold the last reference to this caching
- * topic, but we want to make sure the unsubscribe finishes
- * before kicking of the caching topic's dtor.
+ /*
+ * The subscription may hold the last reference to this caching
+ * topic, but we want to make sure the unsubscribe finishes
+ * before kicking of the caching topic's dtor.
+ */
+ ao2_ref(caching_topic, +1);
+
+ if (stasis_subscription_is_subscribed(caching_topic->sub)) {
+ /*
+ * Increment the reference to hold on to it past the
+ * unsubscribe. Will be cleaned up in dtor.
*/
- ao2_ref(caching_topic, +1);
- hold_ref = caching_topic;
-
- if (stasis_subscription_is_subscribed(caching_topic->sub)) {
- /* Increment the reference to hold on to it past the
- * unsubscribe. Will be cleaned up in dtor. */
- ao2_ref(caching_topic->sub, +1);
- stasis_unsubscribe(caching_topic->sub);
- } else {
- ast_log(LOG_ERROR, "stasis_caching_topic unsubscribed multiple times\n");
- }
+ ao2_ref(caching_topic->sub, +1);
+ stasis_unsubscribe(caching_topic->sub);
+ } else {
+ ast_log(LOG_ERROR, "stasis_caching_topic unsubscribed multiple times\n");
}
+ ao2_cleanup(caching_topic);
return NULL;
}
@@ -325,20 +328,13 @@ STASIS_MESSAGE_TYPE_DEFN(stasis_cache_update_type);
struct stasis_message *stasis_cache_clear_create(struct stasis_message *id_message)
{
- RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
-
- msg = stasis_message_create(stasis_cache_clear_type(), id_message);
- if (!msg) {
- return NULL;
- }
-
- ao2_ref(msg, +1);
- return msg;
+ return stasis_message_create(stasis_cache_clear_type(), id_message);
}
static void stasis_cache_update_dtor(void *obj)
{
struct stasis_cache_update *update = obj;
+
ao2_cleanup(update->old_snapshot);
update->old_snapshot = NULL;
ao2_cleanup(update->new_snapshot);
@@ -349,8 +345,8 @@ static void stasis_cache_update_dtor(void *obj)
static struct stasis_message *update_create(struct stasis_message *old_snapshot, struct stasis_message *new_snapshot)
{
- RAII_VAR(struct stasis_cache_update *, update, NULL, ao2_cleanup);
- RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
+ struct stasis_cache_update *update;
+ struct stasis_message *msg;
ast_assert(old_snapshot != NULL || new_snapshot != NULL);
@@ -376,11 +372,8 @@ static struct stasis_message *update_create(struct stasis_message *old_snapshot,
}
msg = stasis_message_create(stasis_cache_update_type(), update);
- if (!msg) {
- return NULL;
- }
- ao2_ref(msg, +1);
+ ao2_cleanup(update);
return msg;
}