rc = LDAP_SUCCESS;
 
                                } else {
-                                       LBER_FREE( attr->a_vals[i].bv_val );
+                                       ber_memfree( attr->a_vals[i].bv_val );
                                        if ( --last == i ) {
                                                BER_BVZERO( &attr->a_vals[i] );
                                                break;
                        }
 
                        if ( rc == LDAP_SUCCESS && pretty ) {
-                               LBER_FREE( attr->a_vals[i].bv_val );
+                               ber_memfree( attr->a_vals[i].bv_val );
                                attr->a_vals[i] = pval;
                        }
                }
                                        NULL );
 
                                if ( rc != LDAP_SUCCESS ) {
-                                       LBER_FREE( attr->a_vals[i].bv_val );
+                                       ber_memfree( attr->a_vals[i].bv_val );
                                        if ( --last == i ) {
                                                BER_BVZERO( &attr->a_vals[i] );
                                                break;
 
                                /* Strip duplicate values */
                                if ( attr->a_nvals != attr->a_vals )
-                                       LBER_FREE( attr->a_nvals[i].bv_val );
-                               LBER_FREE( attr->a_vals[i].bv_val );
+                                       ber_memfree( attr->a_nvals[i].bv_val );
+                               ber_memfree( attr->a_vals[i].bv_val );
                                attr->a_numvals--;
 
                                assert( i >= 0 );
 
                         * legal to trim values when adding/modifying;
                         * it should be when searching (e.g. ACLs).
                         */
-                       LBER_FREE( a_vals[ i ].bv_val );
+                       ber_memfree( a_vals[ i ].bv_val );
                        if ( last > i ) {
                                a_vals[ i ] = a_vals[ last ];
                        }
                         * legal to trim values when adding/modifying;
                         * it should be when searching (e.g. ACLs).
                         */
-                       LBER_FREE( a_vals[i].bv_val );
+                       ber_memfree( a_vals[i].bv_val );
                        if ( last > i ) {
                                a_vals[i] = a_vals[last];
                        }
                default:
                        /* leave attr untouched if massage failed */
                        if ( !BER_BVISNULL( &bv ) && a_vals[i].bv_val != bv.bv_val ) {
-                               LBER_FREE( a_vals[i].bv_val );
+                               ber_memfree( a_vals[i].bv_val );
                                a_vals[i] = bv;
                        }
                        break;
 
                                }
 
                                if ( rc ) {
-                                       LBER_FREE( attr->a_vals[i].bv_val );
+                                       ber_memfree( attr->a_vals[i].bv_val );
                                        if ( --last == i ) {
                                                BER_BVZERO( &attr->a_vals[ i ] );
                                                break;
                                }
 
                                if ( pretty ) {
-                                       LBER_FREE( attr->a_vals[i].bv_val );
+                                       ber_memfree( attr->a_vals[i].bv_val );
                                        attr->a_vals[i] = pval;
                                }
                        }
                                        attr->a_desc->ad_type->sat_equality,
                                        &attr->a_vals[i], &attr->a_nvals[i],
                                        NULL )) {
-                                       LBER_FREE( attr->a_vals[i].bv_val );
+                                       ber_memfree( attr->a_vals[i].bv_val );
                                        if ( --last == i ) {
                                                BER_BVZERO( &attr->a_vals[ i ] );
                                                break;
 
                                        /* Strip duplicate values */
                                        if ( attr->a_nvals != attr->a_vals )
-                                               LBER_FREE( attr->a_nvals[i].bv_val );
-                                       LBER_FREE( attr->a_vals[i].bv_val );
+                                               ber_memfree( attr->a_nvals[i].bv_val );
+                                       ber_memfree( attr->a_vals[i].bv_val );
                                        attr->a_numvals--;
                                        if ( (unsigned)i < attr->a_numvals ) {
                                                attr->a_vals[i] = attr->a_vals[attr->a_numvals];