3 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright (c) 1994 The Regents of the University of Michigan.
10 * free.c - some free routines are included here to avoid having to
11 * link in lots of extra code when not using certain features
17 #include <ac/stdlib.h>
19 #include <ac/string.h>
28 ldap_memfree( void *p )
34 ldap_memvfree( void **v )
40 ldap_memalloc( ber_len_t s )
42 return LDAP_MALLOC( s );
46 ldap_memcalloc( ber_len_t n, ber_len_t s )
48 return LDAP_CALLOC( n, s );
52 ldap_memrealloc( void* p, ber_len_t s )
54 return LDAP_REALLOC( p, s );
58 ldap_strdup( LDAP_CONST char *p )
60 return LDAP_STRDUP( p );
64 * free a null-terminated array of pointers to mod structures. the
65 * structures are freed, not the array itself, unless the freemods
70 ldap_mods_free( LDAPMod **mods, int freemods )
77 for ( i = 0; mods[i] != NULL; i++ ) {
78 if ( mods[i]->mod_op & LDAP_MOD_BVALUES ) {
79 if( mods[i]->mod_bvalues != NULL )
80 ber_bvecfree( mods[i]->mod_bvalues );
82 } else if( mods[i]->mod_values != NULL ) {
83 LDAP_VFREE( mods[i]->mod_values );
86 if ( mods[i]->mod_type != NULL ) {
87 LDAP_FREE( mods[i]->mod_type );
90 LDAP_FREE( (char *) mods[i] );
94 LDAP_FREE( (char *) mods );