diff options
author | Gerald Carter <jerry@samba.org> | 2004-03-22 22:49:40 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2004-03-22 22:49:40 +0000 |
commit | 14dd75d181293fa5335184d2d836834a42edcbb4 (patch) | |
tree | 2c26a8a1dc66ac9c755b08937c7d64954289a544 /source3/libads | |
parent | f58e6a997750c16e0c1ffccabbbf69469eb280c2 (diff) | |
download | samba-14dd75d181293fa5335184d2d836834a42edcbb4.tar.gz samba-14dd75d181293fa5335184d2d836834a42edcbb4.tar.xz samba-14dd75d181293fa5335184d2d836834a42edcbb4.zip |
bug 1195: add flag to ADS_STRUCT so we know who owns the main structure's memory (not the members though)
(This used to be commit 4449e0e251190b741f51348819669453f0758f36)
Diffstat (limited to 'source3/libads')
-rw-r--r-- | source3/libads/ads_struct.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/source3/libads/ads_struct.c b/source3/libads/ads_struct.c index 9774968e121..92f37093f46 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); } } |