[Asterisk-code-review] stasis cache: Remove silly usage of RAII VAR. (asterisk[13])
Corey Farrell
asteriskteam at digium.com
Tue Jan 9 20:38:16 CST 2018
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7914
Change subject: stasis_cache: Remove silly usage of RAII_VAR.
......................................................................
stasis_cache: Remove silly usage of RAII_VAR.
Change-Id: Ifa95e5801c949df296c7e4376347730fb0ed52ef
---
M main/stasis_cache.c
1 file changed, 11 insertions(+), 9 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/14/7914/1
diff --git a/main/stasis_cache.c b/main/stasis_cache.c
index f5037a4..ee9e56d 100644
--- a/main/stasis_cache.c
+++ b/main/stasis_cache.c
@@ -870,9 +870,8 @@
struct stasis_caching_topic *stasis_caching_topic_create(struct stasis_topic *original_topic, struct stasis_cache *cache)
{
- RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, ao2_cleanup);
- struct stasis_subscription *sub;
- RAII_VAR(char *, new_name, NULL, ast_free);
+ struct stasis_caching_topic *caching_topic;
+ char *new_name;
int ret;
ret = ast_asprintf(&new_name, "%s-cached", stasis_topic_name(original_topic));
@@ -883,28 +882,31 @@
caching_topic = ao2_alloc_options(sizeof(*caching_topic),
stasis_caching_topic_dtor, AO2_ALLOC_OPT_LOCK_NOLOCK);
if (caching_topic == NULL) {
+ ast_free(new_name);
+
return NULL;
}
caching_topic->topic = stasis_topic_create(new_name);
+ ast_free(new_name);
if (caching_topic->topic == NULL) {
+ ao2_ref(caching_topic, -1);
+
return NULL;
}
ao2_ref(cache, +1);
caching_topic->cache = cache;
- sub = internal_stasis_subscribe(original_topic, caching_topic_exec, caching_topic, 0, 0);
- if (sub == NULL) {
+ caching_topic->sub = internal_stasis_subscribe(original_topic, caching_topic_exec, caching_topic, 0, 0);
+ if (caching_topic->sub == NULL) {
+ ao2_ref(caching_topic, -1);
+
return NULL;
}
ao2_ref(original_topic, +1);
caching_topic->original_topic = original_topic;
-
- /* This is for the reference contained in the subscription above */
- ao2_ref(caching_topic, +1);
- caching_topic->sub = sub;
/* The subscription holds the reference, so no additional ref bump. */
return caching_topic;
--
To view, visit https://gerrit.asterisk.org/7914
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifa95e5801c949df296c7e4376347730fb0ed52ef
Gerrit-Change-Number: 7914
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180109/26c57765/attachment-0001.html>
More information about the asterisk-code-review
mailing list