fixed some memory allocation nonsense

This commit is contained in:
Pierangelo Masarati 2001-07-29 17:21:28 +00:00
parent c2daca1001
commit 6c81656a95

View File

@ -23,6 +23,10 @@ get_limits(
{ {
struct slap_limits **lm; struct slap_limits **lm;
assert( be );
assert( timelimit );
assert( sizelimit );
/* /*
* default values * default values
*/ */
@ -106,16 +110,15 @@ add_limits(
lm->lm_timelimit = timelimit; lm->lm_timelimit = timelimit;
lm->lm_sizelimit = sizelimit; lm->lm_sizelimit = sizelimit;
if ( be->be_limits == NULL ) { i = 0;
i = 1; if ( be->be_limits != NULL ) {
be->be_limits = ( struct slap_limits ** )ch_calloc( sizeof( struct slap_limits * ), 2 ); for ( ; be->be_limits[i]; i++ );
} else {
for ( i = 0; be->be_limits[i]; i++ );
be->be_limits = ( struct slap_limits ** )ch_realloc( be->be_limits,
sizeof( struct slap_limits * ) * ( i + 1 ) );
} }
be->be_limits = ( struct slap_limits ** )ch_realloc( be->be_limits,
sizeof( struct slap_limits * ) * ( i + 2 ) );
be->be_limits[i] = lm; be->be_limits[i] = lm;
be->be_limits[i+1] = NULL;
return( 0 ); return( 0 );
} }