summaryrefslogtreecommitdiff
path: root/source3/libads/ads_struct.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libads/ads_struct.c')
-rw-r--r--source3/libads/ads_struct.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/source3/libads/ads_struct.c b/source3/libads/ads_struct.c
index 9774968e12..92f37093f4 100644
--- a/source3/libads/ads_struct.c
+++ b/source3/libads/ads_struct.c
@@ -102,13 +102,10 @@ ADS_STRUCT *ads_init(const char *realm,
ads->server.foreign = 1;
}
- return ads;
-}
+ /* the caller will own the memory by default */
+ ads->is_mine = 1;
-/* a simpler ads_init() interface using all defaults */
-ADS_STRUCT *ads_init_simple(void)
-{
- return ads_init(NULL, NULL, NULL);
+ return ads;
}
/*
@@ -117,6 +114,9 @@ ADS_STRUCT *ads_init_simple(void)
void ads_destroy(ADS_STRUCT **ads)
{
if (ads && *ads) {
+ BOOL is_mine;
+
+ is_mine = (*ads)->is_mine;
#if HAVE_LDAP
if ((*ads)->ld) ldap_unbind((*ads)->ld);
#endif
@@ -133,8 +133,11 @@ void ads_destroy(ADS_STRUCT **ads)
SAFE_FREE((*ads)->config.realm);
SAFE_FREE((*ads)->config.bind_path);
SAFE_FREE((*ads)->config.ldap_server_name);
-
+
+
ZERO_STRUCTP(*ads);
- SAFE_FREE(*ads);
+
+ if ( is_mine )
+ SAFE_FREE(*ads);
}
}