summaryrefslogtreecommitdiff
path: root/main/stasis_cache.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2018-01-09 12:10:27 -0500
committerCorey Farrell <git@cfware.com>2018-01-09 20:43:17 -0600
commit01127e16641759bd8f9f4502bb0a33702fc993d2 (patch)
tree247318513bc1f1959f2632d17823e97f18d62b60 /main/stasis_cache.c
parent9397c2535cebcbec3731e7f61c38f1eefaae0f1f (diff)
stasis_cache: Remove silly usage of RAII_VAR.
Change-Id: Ifa95e5801c949df296c7e4376347730fb0ed52ef
Diffstat (limited to 'main/stasis_cache.c')
-rw-r--r--main/stasis_cache.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/main/stasis_cache.c b/main/stasis_cache.c
index 3bcf0c416..ca17bdd26 100644
--- a/main/stasis_cache.c
+++ b/main/stasis_cache.c
@@ -868,9 +868,8 @@ static void caching_topic_exec(void *data, struct stasis_subscription *sub,
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));
@@ -881,29 +880,32 @@ struct stasis_caching_topic *stasis_caching_topic_create(struct stasis_topic *or
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;
}