diff options
Diffstat (limited to 'main/astobj2.c')
-rw-r--r-- | main/astobj2.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/main/astobj2.c b/main/astobj2.c index 0dd07103c..4c82ea467 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -638,6 +638,7 @@ void __ao2_global_obj_release(struct ao2_global_obj *holder, const char *tag, co { if (!holder) { /* For sanity */ + ast_log(LOG_ERROR, "Must be called with a global object!\n"); return; } if (__ast_rwlock_wrlock(file, line, func, &holder->lock, name)) { @@ -660,6 +661,7 @@ void *__ao2_global_obj_replace(struct ao2_global_obj *holder, void *obj, const c if (!holder) { /* For sanity */ + ast_log(LOG_ERROR, "Must be called with a global object!\n"); return NULL; } if (__ast_rwlock_wrlock(file, line, func, &holder->lock, name)) { @@ -696,8 +698,10 @@ void *__ao2_global_obj_ref(struct ao2_global_obj *holder, const char *tag, const if (!holder) { /* For sanity */ + ast_log(LOG_ERROR, "Must be called with a global object!\n"); return NULL; } + if (__ast_rwlock_rdlock(file, line, func, &holder->lock, name)) { /* Could not get the read lock. */ return NULL; @@ -713,7 +717,6 @@ void *__ao2_global_obj_ref(struct ao2_global_obj *holder, const char *tag, const return obj; } - /* internal callback to destroy a container. */ static void container_destruct(void *c); @@ -1519,6 +1522,20 @@ struct ao2_container *__ao2_container_clone_debug(struct ao2_container *orig, en return clone; } +void ao2_cleanup(void *obj) +{ + if (obj) { + ao2_ref(obj, -1); + } +} + +void ao2_iterator_cleanup(struct ao2_iterator *iter) +{ + if (iter) { + ao2_iterator_destroy(iter); + } +} + #ifdef AO2_DEBUG static int print_cb(void *obj, void *arg, int flag) { |