- Modifications *modlist = NULL;
- Modifications **modtail = &modlist;
- Modifications tmp;
-
- int rc = LDAP_SUCCESS;
- int i;
-
- const char *text = NULL;
-
-
- op = (Operation *) slapi_ch_calloc(1, sizeof(Operation));
- if ( pEntry == NULL) {
- rc = LDAP_NO_MEMORY;
- goto cleanup;
- }
- op->o_tag = LDAP_REQ_ADD;
-
- pEntry = (Entry *) ch_calloc( 1, sizeof(Entry) );
- if ( pEntry == NULL) {
- rc = LDAP_NO_MEMORY;
- goto cleanup;
- }
-
- dn.bv_val = slapi_ch_strdup(ldn);
- dn.bv_len = strlen(ldn);
-
- rc = dnPrettyNormal( NULL, &dn, &pEntry->e_name, &pEntry->e_nname );
- if (rc != LDAP_SUCCESS) goto cleanup;
-
- if ( rc == LDAP_SUCCESS ) {
- for ( i=0, pMod=mods[0]; rc == LDAP_SUCCESS && pMod != NULL; pMod=mods[++i]) {
- Modifications *mod;
- if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) {
- /* attr values are in berval format */
- /* convert an array of pointers to bervals to an array of bervals */
- rc = bvptr2obj(pMod->mod_bvalues, &bv);
- if (rc != LDAP_SUCCESS) goto cleanup;
- tmp.sml_type.bv_val = pMod->mod_type;
- tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_bvalues = bv;
-#ifdef SLAP_NVALUES
- tmp.sml_nvalues = NULL;
-#endif
-
- mod = (Modifications *) ch_malloc( sizeof(Modifications) );
-
- mod->sml_op = LDAP_MOD_ADD;
- mod->sml_next = NULL;
- mod->sml_desc = NULL;
- mod->sml_type = tmp.sml_type;
- mod->sml_bvalues = tmp.sml_bvalues;
-#ifdef SLAP_NVALUES
- mod->sml_nvalues = tmp.sml_nvalues;
-#endif
-
- *modtail = mod;
- modtail = &mod->sml_next;
-
- } else {
- /* attr values are in string format, need to be converted */
- /* to an array of bervals */
- if ( pMod->mod_values == NULL ) {
- rc = LDAP_OTHER;
- } else {
- rc = values2obj( pMod->mod_values, &bv );
- if (rc != LDAP_SUCCESS) goto cleanup;
- tmp.sml_type.bv_val = pMod->mod_type;
- tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_bvalues = bv;
-#ifdef SLAP_NVALUES
- tmp.sml_nvalues = NULL;
-#endif
-
- mod = (Modifications *) ch_malloc( sizeof(Modifications) );
-
- mod->sml_op = LDAP_MOD_ADD;
- mod->sml_next = NULL;
- mod->sml_desc = NULL;
- mod->sml_type = tmp.sml_type;
- mod->sml_bvalues = tmp.sml_bvalues;
-#ifdef SLAP_NVALUES
- mod->sml_nvalues = tmp.sml_nvalues;
-#endif
-
- *modtail = mod;
- modtail = &mod->sml_next;
- }
- }
- } /* for each LDAPMod */
+ PBLOCK_ASSERT_INTOP( pb, 0 );
+
+ conn = pb->pb_conn;
+ op = pb->pb_op;
+
+ /* free allocated DNs */
+ if ( !BER_BVISNULL( &op->o_dn ) )
+ op->o_tmpfree( op->o_dn.bv_val, op->o_tmpmemctx );
+ if ( !BER_BVISNULL( &op->o_ndn ) )
+ op->o_tmpfree( op->o_ndn.bv_val, op->o_tmpmemctx );
+
+ if ( !BER_BVISNULL( &op->o_req_dn ) )
+ op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
+ if ( !BER_BVISNULL( &op->o_req_ndn ) )
+ op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
+
+ switch ( op->o_tag ) {
+ case LDAP_REQ_MODRDN:
+ if ( !BER_BVISNULL( &op->orr_newrdn ))
+ op->o_tmpfree( op->orr_newrdn.bv_val, op->o_tmpmemctx );
+ if ( !BER_BVISNULL( &op->orr_nnewrdn ))
+ op->o_tmpfree( op->orr_nnewrdn.bv_val, op->o_tmpmemctx );
+ if ( op->orr_newSup != NULL ) {
+ assert( !BER_BVISNULL( op->orr_newSup ) );
+ op->o_tmpfree( op->orr_newSup->bv_val, op->o_tmpmemctx );
+ op->o_tmpfree( op->orr_newSup, op->o_tmpmemctx );
+ }
+ if ( op->orr_nnewSup != NULL ) {
+ assert( !BER_BVISNULL( op->orr_nnewSup ) );
+ op->o_tmpfree( op->orr_nnewSup->bv_val, op->o_tmpmemctx );
+ op->o_tmpfree( op->orr_nnewSup, op->o_tmpmemctx );
+ }
+ break;
+ case LDAP_REQ_ADD:
+ slap_mods_free( op->ora_modlist, 0 );
+ break;
+ case LDAP_REQ_MODIFY:
+ slap_mods_free( op->orm_modlist, 1 );
+ break;
+ case LDAP_REQ_SEARCH:
+ if ( op->ors_attrs != NULL ) {
+ op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx );
+ op->ors_attrs = NULL;
+ }
+ break;
+ default:
+ break;