mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 20:04:50 +00:00
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 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@412414 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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))) {
|
if (!(ds = ast_channel_datastore_find(chan, &feature_ds_info, NULL))) {
|
||||||
/* Hasn't been created yet. Trigger creation. */
|
/* 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);
|
ds = ast_channel_datastore_find(chan, &feature_ds_info, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1915,28 +1915,22 @@ void ast_rtp_publish_rtcp_message(struct ast_rtp_instance *rtp,
|
|||||||
struct ast_rtp_rtcp_report *report,
|
struct ast_rtp_rtcp_report *report,
|
||||||
struct ast_json *blob)
|
struct ast_json *blob)
|
||||||
{
|
{
|
||||||
RAII_VAR(struct rtcp_message_payload *, payload,
|
RAII_VAR(struct rtcp_message_payload *, payload, NULL, ao2_cleanup);
|
||||||
ao2_alloc(sizeof(*payload), rtcp_message_payload_dtor), ao2_cleanup);
|
|
||||||
RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
|
|
||||||
RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
|
RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
|
||||||
|
|
||||||
|
payload = ao2_alloc(sizeof(*payload), rtcp_message_payload_dtor);
|
||||||
if (!payload || !report) {
|
if (!payload || !report) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ast_strlen_zero(rtp->channel_uniqueid)) {
|
if (!ast_strlen_zero(rtp->channel_uniqueid)) {
|
||||||
snapshot = ast_channel_snapshot_get_latest(rtp->channel_uniqueid);
|
payload->snapshot = ast_channel_snapshot_get_latest(rtp->channel_uniqueid);
|
||||||
if (snapshot) {
|
|
||||||
ao2_ref(snapshot, +1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blob) {
|
if (blob) {
|
||||||
|
payload->blob = blob;
|
||||||
ast_json_ref(blob);
|
ast_json_ref(blob);
|
||||||
}
|
}
|
||||||
ao2_ref(report, 1);
|
ao2_ref(report, +1);
|
||||||
payload->snapshot = snapshot;
|
|
||||||
payload->blob = blob;
|
|
||||||
payload->report = report;
|
payload->report = report;
|
||||||
|
|
||||||
message = stasis_message_create(message_type, payload);
|
message = stasis_message_create(message_type, payload);
|
||||||
|
@@ -172,8 +172,8 @@ static void channel_snapshot_dtor(void *obj)
|
|||||||
|
|
||||||
struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *chan)
|
struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *chan)
|
||||||
{
|
{
|
||||||
RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
|
struct ast_channel_snapshot *snapshot;
|
||||||
RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
|
struct ast_bridge *bridge;
|
||||||
char nativeformats[256];
|
char nativeformats[256];
|
||||||
struct ast_str *write_transpath = ast_str_alloca(256);
|
struct ast_str *write_transpath = ast_str_alloca(256);
|
||||||
struct ast_str *read_transpath = ast_str_alloca(256);
|
struct ast_str *read_transpath = ast_str_alloca(256);
|
||||||
@@ -187,6 +187,7 @@ struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *cha
|
|||||||
|
|
||||||
snapshot = ao2_alloc(sizeof(*snapshot), channel_snapshot_dtor);
|
snapshot = ao2_alloc(sizeof(*snapshot), channel_snapshot_dtor);
|
||||||
if (!snapshot || ast_string_field_init(snapshot, 1024)) {
|
if (!snapshot || ast_string_field_init(snapshot, 1024)) {
|
||||||
|
ao2_cleanup(snapshot);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,6 +232,7 @@ struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *cha
|
|||||||
|
|
||||||
if ((bridge = ast_channel_get_bridge(chan))) {
|
if ((bridge = ast_channel_get_bridge(chan))) {
|
||||||
ast_string_field_set(snapshot, bridgeid, bridge->uniqueid);
|
ast_string_field_set(snapshot, bridgeid, bridge->uniqueid);
|
||||||
|
ao2_cleanup(bridge);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_string_field_set(snapshot, nativeformats, ast_getformatname_multiple(nativeformats, sizeof(nativeformats),
|
ast_string_field_set(snapshot, nativeformats, ast_getformatname_multiple(nativeformats, sizeof(nativeformats),
|
||||||
@@ -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->channel_vars = ast_channel_get_vars(chan);
|
||||||
snapshot->tech_properties = ast_channel_tech(chan)->properties;
|
snapshot->tech_properties = ast_channel_tech(chan)->properties;
|
||||||
|
|
||||||
ao2_ref(snapshot, +1);
|
|
||||||
return snapshot;
|
return snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -890,11 +890,10 @@ static void generate_or_link_lots_to_configs(void)
|
|||||||
struct parking_lot_cfg *lot_cfg;
|
struct parking_lot_cfg *lot_cfg;
|
||||||
struct ao2_iterator iter;
|
struct ao2_iterator iter;
|
||||||
|
|
||||||
for (iter = ao2_iterator_init(cfg->parking_lots, 0); (lot_cfg = ao2_iterator_next(&iter)); ao2_ref(lot_cfg, -1)) {
|
iter = ao2_iterator_init(cfg->parking_lots, 0);
|
||||||
RAII_VAR(struct parking_lot *, lot, NULL, ao2_cleanup);
|
for (; (lot_cfg = ao2_iterator_next(&iter)); ao2_ref(lot_cfg, -1)) {
|
||||||
lot = parking_lot_build_or_update(lot_cfg, 0);
|
ao2_cleanup(parking_lot_build_or_update(lot_cfg, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
ao2_iterator_destroy(&iter);
|
ao2_iterator_destroy(&iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user