- i = 0;
- if ( rs->sr_ctrls ) {
- for ( ; rs->sr_ctrls[ i ] != NULL; i++ )
- /* count'em */ ;
- }
- i += 2;
- ctrlsp = op->o_tmpcalloc( i, sizeof(LDAPControl *), op->o_tmpmemctx );
- i = 0;
- if ( rs->sr_ctrls != NULL ) {
- for ( ; rs->sr_ctrls[ i ] != NULL; i++ ) {
- ctrlsp[ i ] = rs->sr_ctrls[ i ];
- }
- }
- ctrlsp[ i++ ] = ctrl;
- ctrlsp[ i++ ] = NULL;
- if ( rs->sr_flags & REP_CTRLS_MUSTBEFREED ) {
- op->o_tmpfree( rs->sr_ctrls, op->o_tmpmemctx );
- }
- rs->sr_ctrls = ctrlsp;
- rs->sr_flags |= REP_CTRLS_MUSTBEFREED;