2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 * Copyright (c) 1994 The Regents of the University of Michigan.
9 * free.c - some free routines are included here to avoid having to
10 * link in lots of extra code when not using certain features
19 #include <ac/string.h>
28 ldap_memfree( void *p )
34 ldap_memalloc( size_t s )
36 return LDAP_MALLOC( s );
40 ldap_memcalloc( size_t n, size_t s )
42 return LDAP_CALLOC( n, s );
46 ldap_memrealloc( void* p, size_t s )
48 return LDAP_REALLOC( p, s );
52 ldap_getfilter_free( LDAPFiltDesc *lfdp )
54 LDAPFiltList *flp, *nextflp;
55 LDAPFiltInfo *fip, *nextfip;
57 for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = nextflp ) {
58 for ( fip = flp->lfl_ilist; fip != NULL; fip = nextfip ) {
59 nextfip = fip->lfi_next;
60 LDAP_FREE( fip->lfi_filter );
61 LDAP_FREE( fip->lfi_desc );
64 nextflp = flp->lfl_next;
65 LDAP_FREE( flp->lfl_pattern );
66 LDAP_FREE( flp->lfl_delims );
67 LDAP_FREE( flp->lfl_tag );
71 if ( lfdp->lfd_curvalcopy != NULL ) {
72 LDAP_FREE( lfdp->lfd_curvalcopy );
74 if ( lfdp->lfd_curvalwords != NULL ) {
75 LDAP_FREE( lfdp->lfd_curvalwords );
77 if ( lfdp->lfd_filtprefix != NULL ) {
78 LDAP_FREE( lfdp->lfd_filtprefix );
80 if ( lfdp->lfd_filtsuffix != NULL ) {
81 LDAP_FREE( lfdp->lfd_filtsuffix );
88 * free a null-terminated array of pointers to mod structures. the
89 * structures are freed, not the array itself, unless the freemods
94 ldap_mods_free( LDAPMod **mods, int freemods )
101 for ( i = 0; mods[i] != NULL; i++ ) {
102 if ( mods[i]->mod_op & LDAP_MOD_BVALUES ) {
103 ber_bvecfree( mods[i]->mod_bvalues );
105 ldap_value_free( mods[i]->mod_values );
107 LDAP_FREE( (char *) mods[i] );
111 LDAP_FREE( (char *) mods );