From 01127e16641759bd8f9f4502bb0a33702fc993d2 Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Tue, 9 Jan 2018 12:10:27 -0500 Subject: stasis_cache: Remove silly usage of RAII_VAR. Change-Id: Ifa95e5801c949df296c7e4376347730fb0ed52ef --- main/stasis_cache.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'main') 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; } -- cgit v1.2.3