[asterisk-commits] rmudgett: trunk r412414 - in /trunk: ./ main/ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 15 13:30:29 CDT 2014


Author: rmudgett
Date: Tue Apr 15 13:30:24 2014
New Revision: 412414

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=412414
Log:
Eliminate some more unnecessary RAII_VAR() uses.

RAII_VAR() is not a hammer appropriate to pound all nails.
........

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

Modified:
    trunk/   (props changed)
    trunk/main/features_config.c
    trunk/main/rtp_engine.c
    trunk/main/stasis_channels.c
    trunk/res/res_parking.c

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

Modified: trunk/main/features_config.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/features_config.c?view=diff&rev=412414&r1=412413&r2=412414
==============================================================================
--- trunk/main/features_config.c (original)
+++ trunk/main/features_config.c Tue Apr 15 13:30:24 2014
@@ -1081,7 +1081,8 @@
 
 	if (!(ds = ast_channel_datastore_find(chan, &feature_ds_info, NULL))) {
 		/* Hasn't been created yet.  Trigger creation. */
-		RAII_VAR(struct features_config *, cfg, get_feature_ds(chan), ao2_cleanup);
+		ao2_cleanup(get_feature_ds(chan));
+
 		ds = ast_channel_datastore_find(chan, &feature_ds_info, NULL);
 	}
 

Modified: trunk/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/rtp_engine.c?view=diff&rev=412414&r1=412413&r2=412414
==============================================================================
--- trunk/main/rtp_engine.c (original)
+++ trunk/main/rtp_engine.c Tue Apr 15 13:30:24 2014
@@ -1915,28 +1915,22 @@
 		struct ast_rtp_rtcp_report *report,
 		struct ast_json *blob)
 {
-	RAII_VAR(struct rtcp_message_payload *, payload,
-			ao2_alloc(sizeof(*payload), rtcp_message_payload_dtor), ao2_cleanup);
-	RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
+	RAII_VAR(struct rtcp_message_payload *, payload, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
 
+	payload = ao2_alloc(sizeof(*payload), rtcp_message_payload_dtor);
 	if (!payload || !report) {
 		return;
 	}
 
 	if (!ast_strlen_zero(rtp->channel_uniqueid)) {
-		snapshot = ast_channel_snapshot_get_latest(rtp->channel_uniqueid);
-		if (snapshot) {
-			ao2_ref(snapshot, +1);
-		}
-	}
-
+		payload->snapshot = ast_channel_snapshot_get_latest(rtp->channel_uniqueid);
+	}
 	if (blob) {
+		payload->blob = blob;
 		ast_json_ref(blob);
 	}
-	ao2_ref(report, 1);
-	payload->snapshot = snapshot;
-	payload->blob = blob;
+	ao2_ref(report, +1);
 	payload->report = report;
 
 	message = stasis_message_create(message_type, payload);

Modified: trunk/main/stasis_channels.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/stasis_channels.c?view=diff&rev=412414&r1=412413&r2=412414
==============================================================================
--- trunk/main/stasis_channels.c (original)
+++ trunk/main/stasis_channels.c Tue Apr 15 13:30:24 2014
@@ -172,8 +172,8 @@
 
 struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *chan)
 {
-	RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	struct ast_channel_snapshot *snapshot;
+	struct ast_bridge *bridge;
 	char nativeformats[256];
 	struct ast_str *write_transpath = ast_str_alloca(256);
 	struct ast_str *read_transpath = ast_str_alloca(256);
@@ -187,6 +187,7 @@
 
 	snapshot = ao2_alloc(sizeof(*snapshot), channel_snapshot_dtor);
 	if (!snapshot || ast_string_field_init(snapshot, 1024)) {
+		ao2_cleanup(snapshot);
 		return NULL;
 	}
 
@@ -231,6 +232,7 @@
 
 	if ((bridge = ast_channel_get_bridge(chan))) {
 		ast_string_field_set(snapshot, bridgeid, bridge->uniqueid);
+		ao2_cleanup(bridge);
 	}
 
 	ast_string_field_set(snapshot, nativeformats, ast_getformatname_multiple(nativeformats, sizeof(nativeformats),
@@ -267,7 +269,6 @@
 	snapshot->channel_vars = ast_channel_get_vars(chan);
 	snapshot->tech_properties = ast_channel_tech(chan)->properties;
 
-	ao2_ref(snapshot, +1);
 	return snapshot;
 }
 

Modified: trunk/res/res_parking.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_parking.c?view=diff&rev=412414&r1=412413&r2=412414
==============================================================================
--- trunk/res/res_parking.c (original)
+++ trunk/res/res_parking.c Tue Apr 15 13:30:24 2014
@@ -890,11 +890,10 @@
 	struct parking_lot_cfg *lot_cfg;
 	struct ao2_iterator iter;
 
-	for (iter = ao2_iterator_init(cfg->parking_lots, 0); (lot_cfg = ao2_iterator_next(&iter)); ao2_ref(lot_cfg, -1)) {
-		RAII_VAR(struct parking_lot *, lot, NULL, ao2_cleanup);
-		lot = parking_lot_build_or_update(lot_cfg, 0);
-	}
-
+	iter = ao2_iterator_init(cfg->parking_lots, 0);
+	for (; (lot_cfg = ao2_iterator_next(&iter)); ao2_ref(lot_cfg, -1)) {
+		ao2_cleanup(parking_lot_build_or_update(lot_cfg, 0));
+	}
 	ao2_iterator_destroy(&iter);
 }
 




More information about the asterisk-commits mailing list