[asterisk-commits] rmudgett: trunk r409273 - in /trunk: ./ main/stasis_cache.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Feb 28 18:02:04 CST 2014


Author: rmudgett
Date: Fri Feb 28 18:02:02 2014
New Revision: 409273

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=409273
Log:
stasis_cache.c: Remove some unnecessary RAII_VAR() usage.
........

Merged revisions 409272 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/main/stasis_cache.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: trunk/main/stasis_cache.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/stasis_cache.c?view=diff&rev=409273&r1=409272&r2=409273
==============================================================================
--- trunk/main/stasis_cache.c (original)
+++ trunk/main/stasis_cache.c Fri Feb 28 18:02:02 2014
@@ -57,7 +57,8 @@
 	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_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);
-
-		/* 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.
+	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.
+	 */
+	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 @@
 
 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 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 @@
 	}
 
 	msg = stasis_message_create(stasis_cache_update_type(), update);
-	if (!msg) {
-		return NULL;
-	}
-
-	ao2_ref(msg, +1);
+
+	ao2_cleanup(update);
 	return msg;
 }
 




More information about the asterisk-commits mailing list