From cff4a89e38078337d74aa558f0e628d5756b3bba Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Wed, 9 Oct 2013 15:20:38 +0200 Subject: idmap: add internal function to free a domain struct --- src/lib/idmap/sss_idmap.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lib/idmap/sss_idmap.c b/src/lib/idmap/sss_idmap.c index c7ac0c70..45797f22 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); -- cgit