From 5e9daa3af6b1d5ef178ad8737e98908543aa66eb Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Wed, 9 Oct 2013 15:20:38 +0200 Subject: [PATCH 1/5] idmap: add internal function to free a domain struct --- src/lib/idmap/sss_idmap.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lib/idmap/sss_idmap.c b/src/lib/idmap/sss_idmap.c index c7ac0c7..45797f2 100644 --- a/src/lib/idmap/sss_idmap.c +++ b/src/lib/idmap/sss_idmap.c @@ -213,6 +213,20 @@ enum idmap_error_code sss_idmap_init(idmap_alloc_func *alloc_func, return IDMAP_SUCCESS; } +static void sss_idmap_free_domain(struct sss_idmap_ctx *ctx, + struct idmap_domain_info *dom) +{ + if (ctx == NULL || dom == NULL) { + return; + } + + ctx->free_func(dom->range_id, ctx->alloc_pvt); + ctx->free_func(dom->range, ctx->alloc_pvt); + ctx->free_func(dom->name, ctx->alloc_pvt); + ctx->free_func(dom->sid, ctx->alloc_pvt); + ctx->free_func(dom, ctx->alloc_pvt); +} + enum idmap_error_code sss_idmap_free(struct sss_idmap_ctx *ctx) { struct idmap_domain_info *dom; @@ -224,10 +238,7 @@ enum idmap_error_code sss_idmap_free(struct sss_idmap_ctx *ctx) while (next) { dom = next; next = dom->next; - ctx->free_func(dom->range, ctx->alloc_pvt); - ctx->free_func(dom->name, ctx->alloc_pvt); - ctx->free_func(dom->sid, ctx->alloc_pvt); - ctx->free_func(dom, ctx->alloc_pvt); + sss_idmap_free_domain(ctx, dom); } ctx->free_func(ctx, ctx->alloc_pvt); -- 1.7.7.6