diff options
-rw-r--r-- | pjlib/include/pj/pool.h | 9 | ||||
-rw-r--r-- | pjlib/include/pj/pool_i.h | 7 |
2 files changed, 16 insertions, 0 deletions
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); +} |