ldap_ber_free() function frees a BerElement structure from memory. Call this function to free any BerElement structures that you have allocated.
#include <ldap.h>
void ldap_ber_free( BerElement *ber, int freebuf );
ber |
Pointer to the |
freebuf |
Specifies whether or not to free the buffer in the |
BerElement structures allocated by ldap_first_attribute() function calls and by ldap_next_attribute() function calls.
When freeing structures allocated by these functions, you should specify 0 for the freebuf argument. (These functions do not allocate the extra buffer in the BerElement structure.)
For example, to retrieve attributes from a search result entry, you need to call the ldap_first_attribute() function. Calling this function allocates a BerElement structure, which is used to keep track of the current attribute. When you are done working with the attributes, you should free this structure from memory if the structure still exists.
BerElement structure allocated by the ldap_first_attribute() function.
LDAP *ld;
LDAPMessage *a, *e;
BerElement *ber;
...
for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
a =ldap_next_attribute( ld, e, ber ) {
...
/* Retrieve the value of each attribute */
...
}
/* Free the BerElement when done */
if ( ber != NULL ) {ldap_ber_free( ber, 0 );
}
...
ldap_first_attribute(), ldap_next_attribute().
Last Updated: 10/01/98 17:06:23