diff options
author | Pavel Březina <pbrezina@redhat.com> | 2013-09-02 13:36:25 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-09-17 16:02:19 +0200 |
commit | a473fb88e6015cf0ccbd2e9005c7e6acca18f452 (patch) | |
tree | 49546bec7a5fe3789fd841421af6786c35df87ab /src/providers | |
parent | d0017ae54df06b1be7f6878e6f3bfeabe93c2290 (diff) | |
download | sssd-a473fb88e6015cf0ccbd2e9005c7e6acca18f452.tar.gz sssd-a473fb88e6015cf0ccbd2e9005c7e6acca18f452.tar.bz2 sssd-a473fb88e6015cf0ccbd2e9005c7e6acca18f452.zip |
util: add sss_idmap_talloc[_free]
Remove code duplication.
Diffstat (limited to 'src/providers')
-rw-r--r-- | src/providers/ad/ad_subdomains.c | 14 | ||||
-rw-r--r-- | src/providers/ipa/ipa_idmap.c | 17 | ||||
-rw-r--r-- | src/providers/ldap/sdap_idmap.c | 17 |
3 files changed, 9 insertions, 39 deletions
diff --git a/src/providers/ad/ad_subdomains.c b/src/providers/ad/ad_subdomains.c index afd2031f..87685088 100644 --- a/src/providers/ad/ad_subdomains.c +++ b/src/providers/ad/ad_subdomains.c @@ -24,6 +24,7 @@ #include "providers/ldap/sdap_async.h" #include "providers/ad/ad_subdomains.h" +#include "util/util_sss_idmap.h" #include <ctype.h> #include <ndr.h> #include <ndr/ndr_nbt.h> @@ -777,16 +778,6 @@ struct bet_ops ad_subdomains_ops = { .finalize = NULL }; -static void *idmap_talloc(size_t size, void *pvt) -{ - return talloc_size(pvt, size); -} - -static void idmap_free(void *ptr, void *pvt) -{ - talloc_free(ptr); -} - int ad_subdom_init(struct be_ctx *be_ctx, struct ad_id_ctx *id_ctx, const char *ad_domain, @@ -825,7 +816,8 @@ int ad_subdom_init(struct be_ctx *be_ctx, DEBUG(SSSDBG_MINOR_FAILURE, ("Failed to add subdom offline callback")); } - err = sss_idmap_init(idmap_talloc, ctx, idmap_free, &ctx->idmap_ctx); + err = sss_idmap_init(sss_idmap_talloc, ctx, sss_idmap_talloc_free, + &ctx->idmap_ctx); if (err != IDMAP_SUCCESS) { DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to initialize idmap context.\n")); return EFAULT; diff --git a/src/providers/ipa/ipa_idmap.c b/src/providers/ipa/ipa_idmap.c index 69ab55c9..2f141f8e 100644 --- a/src/providers/ipa/ipa_idmap.c +++ b/src/providers/ipa/ipa_idmap.c @@ -24,18 +24,7 @@ #include "util/util.h" #include "providers/ldap/sdap_idmap.h" #include "providers/ipa/ipa_common.h" - -static void * -ipa_idmap_talloc(size_t size, void *pvt) -{ - return talloc_size(pvt, size); -} - -static void -ipa_idmap_talloc_free(void *ptr, void *pvt) -{ - talloc_free(ptr); -} +#include "util/util_sss_idmap.h" errno_t ipa_idmap_find_new_domain(struct sdap_idmap_ctx *idmap_ctx, const char *dom_name, @@ -168,8 +157,8 @@ errno_t ipa_idmap_init(TALLOC_CTX *mem_ctx, idmap_ctx->find_new_domain = ipa_idmap_find_new_domain; /* Initialize the map */ - err = sss_idmap_init(ipa_idmap_talloc, idmap_ctx, - ipa_idmap_talloc_free, + err = sss_idmap_init(sss_idmap_talloc, idmap_ctx, + sss_idmap_talloc_free, &idmap_ctx->map); if (err != IDMAP_SUCCESS) { DEBUG(SSSDBG_CRIT_FAILURE, diff --git a/src/providers/ldap/sdap_idmap.c b/src/providers/ldap/sdap_idmap.c index 7a727719..667e3774 100644 --- a/src/providers/ldap/sdap_idmap.c +++ b/src/providers/ldap/sdap_idmap.c @@ -24,18 +24,7 @@ #include "util/dlinklist.h" #include "util/murmurhash3.h" #include "providers/ldap/sdap_idmap.h" - -static void * -sdap_idmap_talloc(size_t size, void *pvt) -{ - return talloc_size(pvt, size); -} - -static void -sdap_idmap_talloc_free(void *ptr, void *pvt) -{ - talloc_free(ptr); -} +#include "util/util_sss_idmap.h" static errno_t sdap_idmap_add_configured_external_range(struct sdap_idmap_ctx *idmap_ctx) @@ -173,8 +162,8 @@ sdap_idmap_init(TALLOC_CTX *mem_ctx, } /* Initialize the map */ - err = sss_idmap_init(sdap_idmap_talloc, idmap_ctx, - sdap_idmap_talloc_free, + err = sss_idmap_init(sss_idmap_talloc, idmap_ctx, + sss_idmap_talloc_free, &idmap_ctx->map); if (err != IDMAP_SUCCESS) { DEBUG(SSSDBG_CRIT_FAILURE, |