1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
1998-08-09 08:43:13 +08:00
|
|
|
/*
|
2002-01-05 05:17:25 +08:00
|
|
|
* Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
|
1998-12-29 04:53:15 +08:00
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
*/
|
|
|
|
/* Portions
|
1998-08-09 08:43:13 +08:00
|
|
|
* Copyright (c) 1994 The Regents of the University of Michigan.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* free.c - some free routines are included here to avoid having to
|
|
|
|
* link in lots of extra code when not using certain features
|
|
|
|
*/
|
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#include "portable.h"
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#include <stdio.h>
|
1999-06-03 08:37:44 +08:00
|
|
|
#include <ac/stdlib.h>
|
1998-10-25 09:41:42 +08:00
|
|
|
|
|
|
|
#include <ac/string.h>
|
|
|
|
#include <ac/time.h>
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1998-10-26 09:18:41 +08:00
|
|
|
#include "ldap-int.h"
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1998-12-23 02:42:02 +08:00
|
|
|
/*
|
|
|
|
* C-API deallocator
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ldap_memfree( void *p )
|
|
|
|
{
|
1999-05-29 09:19:14 +08:00
|
|
|
LDAP_FREE( p );
|
|
|
|
}
|
|
|
|
|
1999-06-02 03:08:27 +08:00
|
|
|
void
|
|
|
|
ldap_memvfree( void **v )
|
|
|
|
{
|
|
|
|
LDAP_VFREE( v );
|
|
|
|
}
|
|
|
|
|
1999-05-29 09:19:14 +08:00
|
|
|
void *
|
1999-06-19 07:53:05 +08:00
|
|
|
ldap_memalloc( ber_len_t s )
|
1999-05-29 09:19:14 +08:00
|
|
|
{
|
|
|
|
return LDAP_MALLOC( s );
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
1999-06-19 07:53:05 +08:00
|
|
|
ldap_memcalloc( ber_len_t n, ber_len_t s )
|
1999-05-29 09:19:14 +08:00
|
|
|
{
|
|
|
|
return LDAP_CALLOC( n, s );
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
1999-06-19 07:53:05 +08:00
|
|
|
ldap_memrealloc( void* p, ber_len_t s )
|
1999-05-29 09:19:14 +08:00
|
|
|
{
|
|
|
|
return LDAP_REALLOC( p, s );
|
1998-12-23 02:42:02 +08:00
|
|
|
}
|
|
|
|
|
1999-06-04 02:24:22 +08:00
|
|
|
char *
|
|
|
|
ldap_strdup( LDAP_CONST char *p )
|
|
|
|
{
|
|
|
|
return LDAP_STRDUP( p );
|
|
|
|
}
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
void
|
|
|
|
ldap_getfilter_free( LDAPFiltDesc *lfdp )
|
|
|
|
{
|
|
|
|
LDAPFiltList *flp, *nextflp;
|
|
|
|
LDAPFiltInfo *fip, *nextfip;
|
|
|
|
|
|
|
|
for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = nextflp ) {
|
|
|
|
for ( fip = flp->lfl_ilist; fip != NULL; fip = nextfip ) {
|
|
|
|
nextfip = fip->lfi_next;
|
1999-05-29 09:19:14 +08:00
|
|
|
LDAP_FREE( fip->lfi_filter );
|
|
|
|
LDAP_FREE( fip->lfi_desc );
|
|
|
|
LDAP_FREE( fip );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
nextflp = flp->lfl_next;
|
1999-05-29 09:19:14 +08:00
|
|
|
LDAP_FREE( flp->lfl_pattern );
|
|
|
|
LDAP_FREE( flp->lfl_delims );
|
|
|
|
LDAP_FREE( flp->lfl_tag );
|
|
|
|
LDAP_FREE( flp );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( lfdp->lfd_curvalcopy != NULL ) {
|
1999-05-29 09:19:14 +08:00
|
|
|
LDAP_FREE( lfdp->lfd_curvalcopy );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
if ( lfdp->lfd_curvalwords != NULL ) {
|
1999-05-29 09:19:14 +08:00
|
|
|
LDAP_FREE( lfdp->lfd_curvalwords );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
if ( lfdp->lfd_filtprefix != NULL ) {
|
1999-05-29 09:19:14 +08:00
|
|
|
LDAP_FREE( lfdp->lfd_filtprefix );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
if ( lfdp->lfd_filtsuffix != NULL ) {
|
1999-05-29 09:19:14 +08:00
|
|
|
LDAP_FREE( lfdp->lfd_filtsuffix );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
1999-05-29 09:19:14 +08:00
|
|
|
LDAP_FREE( lfdp );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* free a null-terminated array of pointers to mod structures. the
|
|
|
|
* structures are freed, not the array itself, unless the freemods
|
|
|
|
* flag is set.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
ldap_mods_free( LDAPMod **mods, int freemods )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if ( mods == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for ( i = 0; mods[i] != NULL; i++ ) {
|
|
|
|
if ( mods[i]->mod_op & LDAP_MOD_BVALUES ) {
|
1999-06-03 05:38:48 +08:00
|
|
|
if( mods[i]->mod_bvalues != NULL )
|
|
|
|
ber_bvecfree( mods[i]->mod_bvalues );
|
|
|
|
|
|
|
|
} else if( mods[i]->mod_values != NULL ) {
|
|
|
|
LDAP_VFREE( mods[i]->mod_values );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( mods[i]->mod_type != NULL ) {
|
|
|
|
LDAP_FREE( mods[i]->mod_type );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
1999-06-03 05:38:48 +08:00
|
|
|
|
1999-05-29 09:19:14 +08:00
|
|
|
LDAP_FREE( (char *) mods[i] );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
1999-06-06 04:18:32 +08:00
|
|
|
if ( freemods ) {
|
1999-05-29 09:19:14 +08:00
|
|
|
LDAP_FREE( (char *) mods );
|
1999-06-06 04:18:32 +08:00
|
|
|
}
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|