Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

Commit

Permalink
Eliminate some more unnecessary RAII_VAR() uses.
Browse files Browse the repository at this point in the history
RAII_VAR() is not a hammer appropriate to pound all nails.
........

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


git-svn-id: http://svn.asterisk.org/svn/asterisk/trunk@412414 f38db490-d61c-443f-a65b-d21fe96a405b
  • Loading branch information
rmudgett9125 committed Apr 15, 2014
1 parent 0ea6000 commit 82965c1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
3 changes: 2 additions & 1 deletion main/features_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,8 @@ static struct ast_datastore *get_feature_chan_ds(struct ast_channel *chan)

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);
}

Expand Down
16 changes: 5 additions & 11 deletions main/rtp_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1915,28 +1915,22 @@ void ast_rtp_publish_rtcp_message(struct ast_rtp_instance *rtp,
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);
Expand Down
7 changes: 4 additions & 3 deletions main/stasis_channels.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ static void channel_snapshot_dtor(void *obj)

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);
Expand All @@ -187,6 +187,7 @@ struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *cha

snapshot = ao2_alloc(sizeof(*snapshot), channel_snapshot_dtor);
if (!snapshot || ast_string_field_init(snapshot, 1024)) {
ao2_cleanup(snapshot);
return NULL;
}

Expand Down Expand Up @@ -231,6 +232,7 @@ struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *cha

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),
Expand Down Expand Up @@ -267,7 +269,6 @@ struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *cha
snapshot->channel_vars = ast_channel_get_vars(chan);
snapshot->tech_properties = ast_channel_tech(chan)->properties;

ao2_ref(snapshot, +1);
return snapshot;
}

Expand Down
7 changes: 3 additions & 4 deletions res/res_parking.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,11 +890,10 @@ static void generate_or_link_lots_to_configs(void)
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);
}

Expand Down

0 comments on commit 82965c1

Please sign in to comment.