Table of Contents | Previous | Next | Index

Netscape Directory SDK 3.0 for C Programmer’s Guide
     Chapter 18 Functions

ldap_ber_free()

The ldap_ber_free() function frees a BerElement structure from memory. Call this function to free any BerElement structures that you have allocated.

Syntax

#include <ldap.h>
void ldap_ber_free( BerElement *ber, int freebuf );

Parameters

This function has the following parameters:

ber

Pointer to the BerElement structure that you want to free.

freebuf

Specifies whether or not to free the buffer in the BerElement structure.

Description

You can call this function to free 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.

Example

The following example frees the 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 );
}
...

See Also

ldap_first_attribute(), ldap_next_attribute().


Table of Contents | Previous | Next | Index

Last Updated: 10/01/98 17:06:23