From: Michael <mi...@st...> - 2001-07-12 09:39:01
|
HI! Following some more advice by Stig Venaas (see message below) I've ifdef'ed some memory freeing calls provided by Steffen in message.c to keep the source compatible to OpenLDAP 1.2.x libs. I've attached my recent message.c. Backwards compability is not assumed to be crucial in the long run but seems nice if we can achieve it with fairly low efforts. Ciao, Michael. -------- Original Message -------- Subject: Re: python-ldap and OpenLDAP 2 Date: Thu, 12 Jul 2001 10:47:35 +0200 From: Stig Venaas <Sti...@un...> To: Michael Str=F6der <mi...@st...> References: <3B4...@st...> <200...@sv...> <3B4...@st...> <200...@sv...> <3B4...@st...> On Thu, Jul 12, 2001 at 09:31:39AM +0200, Michael Str=F6der wrote: > Stig Venaas wrote: > > = > > These memory leaks was also reported and discussed > > in the OpenLDAP ITS system a few days ago. Someone reported memory > > leaks and Kurt and I responded. See > > http://www.OpenLDAP.org/lists/openldap-bugs/200107/msg00018.html > > for my respons. > = > According to this and Steffen's message the ldap_memfree(attr) and > ber_free(ber, 0) should be ifdef'ed. What about the free(dn) call? > = > Well, we have no problems dropping support for linking against > OpenLDAP 1.x completely if we will have a really stable version and > it's clear that we can achieve all goals on this track. PHP supports OpenLDAP 1.x and others that use the RFC1823 API, as well as Netscape SDK and OpenLDAP 2.x and others that use the new API. The same should be possible for Python. I think I've found a bug in PHP when using old API and ldap_get_dn(). It's not freed! I've never tested much with old API. The PHP code looks like this: #if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS ldap_memfree(dn); #endif For Python you could use: #if ( LDAP_API_VERSION > 2000 ) ldap_memfree(dn); #else free(dn); #endif ldap_memfree() is currently the same as free() but it should be done this way anyway. Regarding the other leaks, you can use code like: #if ( LDAP_API_VERSION > 2000 ) ldap_memfree(attribute); #endif and #if ( LDAP_API_VERSION > 2000 ) if (ber !=3D NULL) ber_free(ber, 0); #endif This way it should work with both old and new APIs. > I have changed the calls to free() to ldap_memfree(), which means > the > code will compile only against OpenLDAP 2.0.x, since 1.2 does not > define ldap_memfree(). Hence the trick above. Stig |