I noticed one of my programs had a pretty bad memory leak, so I checked the manpage for various functions...
Good grief... so many routines called in OpenLDAP dynamically allocate memory for you and require unique and clever ways of deallocating it when you've finished...
A simple search, iterate through the returned entries and then through the attributes for each entry require use of:
free() - for data allocated by ldap_get_dn()
ldap_msgfree() - for ldap_search_st()
ldap_value_free() - for ldap_get_vals()
ldap_memfree() - for ldap_first_attribute() and ldap_next_attribute()
ber_free() - also for ldap_first_attribute() and ldap_next_attribute()
Sheesh!
Good grief... so many routines called in OpenLDAP dynamically allocate memory for you and require unique and clever ways of deallocating it when you've finished...
A simple search, iterate through the returned entries and then through the attributes for each entry require use of:
free() - for data allocated by ldap_get_dn()
ldap_msgfree() - for ldap_search_st()
ldap_value_free() - for ldap_get_vals()
ldap_memfree() - for ldap_first_attribute() and ldap_next_attribute()
ber_free() - also for ldap_first_attribute() and ldap_next_attribute()
Sheesh!