From 8ac264258cc6242cade69f1c5964388bcfc76e15 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Thu, 19 Jan 2017 06:10:15 +0000 Subject: Close #1513: Added pj_pool_safe_release() API. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5533 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/include/pj/pool.h | 9 +++++++++ pjlib/include/pj/pool_i.h | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/pjlib/include/pj/pool.h b/pjlib/include/pj/pool.h index 9adaeca9..59cd86c8 100644 --- a/pjlib/include/pj/pool.h +++ b/pjlib/include/pj/pool.h @@ -390,6 +390,15 @@ PJ_IDECL(pj_pool_t*) pj_pool_create(pj_pool_factory *factory, */ PJ_IDECL(void) pj_pool_release( pj_pool_t *pool ); + +/** + * Release the pool back to pool factory and set the pool pointer to zero. + * + * @param ppool Pointer to memory pool. + */ +PJ_IDECL(void) pj_pool_safe_release( pj_pool_t **ppool ); + + /** * Get pool object name. * diff --git a/pjlib/include/pj/pool_i.h b/pjlib/include/pj/pool_i.h index 2f5d407c..b57530c8 100644 --- a/pjlib/include/pj/pool_i.h +++ b/pjlib/include/pj/pool_i.h @@ -92,3 +92,10 @@ PJ_IDEF(void) pj_pool_release( pj_pool_t *pool ) (*pool->factory->release_pool)(pool->factory, pool); } + +PJ_IDEF(void) pj_pool_safe_release( pj_pool_t **ppool ) +{ + pj_pool_t *pool = *ppool; + *ppool = NULL; + pj_pool_release(pool); +} -- cgit v1.2.3