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
16 #include <ac/stdlib.h>
19 #include <ac/string.h>
28 ldap_memfree( void *p )
34 ldap_memvfree( void **v )
40 ldap_memalloc( size_t s )
42 return LDAP_MALLOC( s );
46 ldap_memcalloc( size_t n, size_t s )
48 return LDAP_CALLOC( n, s );
52 ldap_memrealloc( void* p, size_t s )
54 return LDAP_REALLOC( p, s );
58 ldap_getfilter_free( LDAPFiltDesc *lfdp )
60 LDAPFiltList *flp, *nextflp;
61 LDAPFiltInfo *fip, *nextfip;
63 for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = nextflp ) {
64 for ( fip = flp->lfl_ilist; fip != NULL; fip = nextfip ) {
65 nextfip = fip->lfi_next;
66 LDAP_FREE( fip->lfi_filter );
67 LDAP_FREE( fip->lfi_desc );
70 nextflp = flp->lfl_next;
71 LDAP_FREE( flp->lfl_pattern );
72 LDAP_FREE( flp->lfl_delims );
73 LDAP_FREE( flp->lfl_tag );
77 if ( lfdp->lfd_curvalcopy != NULL ) {
78 LDAP_FREE( lfdp->lfd_curvalcopy );
80 if ( lfdp->lfd_curvalwords != NULL ) {
81 LDAP_FREE( lfdp->lfd_curvalwords );
83 if ( lfdp->lfd_filtprefix != NULL ) {
84 LDAP_FREE( lfdp->lfd_filtprefix );
86 if ( lfdp->lfd_filtsuffix != NULL ) {
87 LDAP_FREE( lfdp->lfd_filtsuffix );
94 * free a null-terminated array of pointers to mod structures. the
95 * structures are freed, not the array itself, unless the freemods
100 ldap_mods_free( LDAPMod **mods, int freemods )
107 for ( i = 0; mods[i] != NULL; i++ ) {
108 if ( mods[i]->mod_op & LDAP_MOD_BVALUES ) {
109 if( mods[i]->mod_bvalues != NULL )
110 ber_bvecfree( mods[i]->mod_bvalues );
112 } else if( mods[i]->mod_values != NULL ) {
113 LDAP_VFREE( mods[i]->mod_values );
116 if ( mods[i]->mod_type != NULL ) {
117 LDAP_FREE( mods[i]->mod_type );
120 LDAP_FREE( (char *) mods[i] );
124 LDAP_FREE( (char *) mods );