]> git.sur5r.net Git - openldap/blob - libraries/libldap/free.c
silence excessive logging
[openldap] / libraries / libldap / free.c
1 /*
2  *  Copyright (c) 1994 The Regents of the University of Michigan.
3  *  All rights reserved.
4  *
5  *  free.c - some free routines are included here to avoid having to
6  *           link in lots of extra code when not using certain features
7  */
8
9 #ifndef lint 
10 static char copyright[] = "@(#) Copyright (c) 1994 The Regents of the University of Michigan.\nAll rights reserved.\n";
11 #endif
12
13
14 #include <stdio.h>
15 #include <string.h>
16 #include <ctype.h>
17 #ifdef MACOS
18 #include <stdlib.h>
19 #include "macos.h"
20 #else /* MACOS */
21 #ifdef DOS
22 #include <malloc.h>
23 #include "msdos.h"
24 #else /* DOS */
25 #include <sys/types.h>
26 #include <stdlib.h>
27 #endif /* DOS */
28 #endif /* MACOS */
29
30 #include "lber.h"
31 #include "ldap.h"
32
33 void
34 ldap_getfilter_free( LDAPFiltDesc *lfdp )
35 {
36     LDAPFiltList        *flp, *nextflp;
37     LDAPFiltInfo        *fip, *nextfip;
38
39     for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = nextflp ) {
40         for ( fip = flp->lfl_ilist; fip != NULL; fip = nextfip ) {
41             nextfip = fip->lfi_next;
42             free( fip->lfi_filter );
43             free( fip->lfi_desc );
44             free( fip );
45         }
46         nextflp = flp->lfl_next;
47         free( flp->lfl_pattern );
48         free( flp->lfl_delims );
49         free( flp->lfl_tag );
50         free( flp );
51     }
52
53     if ( lfdp->lfd_curvalcopy != NULL ) {
54         free( lfdp->lfd_curvalcopy );
55     }
56     if ( lfdp->lfd_curvalwords != NULL ) {
57         free( lfdp->lfd_curvalwords );
58     }
59     if ( lfdp->lfd_filtprefix != NULL ) {
60         free( lfdp->lfd_filtprefix );
61     }
62     if ( lfdp->lfd_filtsuffix != NULL ) {
63         free( lfdp->lfd_filtsuffix );
64     }
65
66     free( lfdp );
67 }
68
69 /*
70  * free a null-terminated array of pointers to mod structures. the
71  * structures are freed, not the array itself, unless the freemods
72  * flag is set.
73  */
74
75 void
76 ldap_mods_free( LDAPMod **mods, int freemods )
77 {
78         int     i;
79
80         if ( mods == NULL )
81                 return;
82
83         for ( i = 0; mods[i] != NULL; i++ ) {
84                 if ( mods[i]->mod_op & LDAP_MOD_BVALUES ) {
85                         ber_bvecfree( mods[i]->mod_bvalues );
86                 } else {
87                         ldap_value_free( mods[i]->mod_values );
88                 }
89                 free( (char *) mods[i] );
90         }
91
92         if ( freemods )
93                 free( (char *) mods );
94 }