]> git.sur5r.net Git - openldap/commitdiff
add entry_dup_to(); use it to address ITS#6172 (thanks to Michael Karcher)
authorPierangelo Masarati <ando@openldap.org>
Mon, 3 Aug 2009 13:18:05 +0000 (13:18 +0000)
committerPierangelo Masarati <ando@openldap.org>
Mon, 3 Aug 2009 13:18:05 +0000 (13:18 +0000)
servers/slapd/back-sql/entry-id.c
servers/slapd/entry.c
servers/slapd/proto-slap.h

index e1351b996728e409c3ebb679c34a7a3844c2fb2e..26f6ced56f29b47c2437620cb5c742102fcddd05 100644 (file)
@@ -934,15 +934,11 @@ backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *eid )
        memset( bsi->bsi_e, 0, sizeof( Entry ) );
 
        if ( bi->sql_baseObject && BACKSQL_IS_BASEOBJECT_ID( &eid->eid_id ) ) {
-               Entry   *e;
-
-               e = entry_dup( bi->sql_baseObject );
-               if ( e == NULL ) {
-                       return LDAP_NO_MEMORY;
+               rc = entry_dup_to( bi->sql_baseObject, bsi->bsi_e );
+               if ( rc != LDAP_SUCCESS ) {
+                       return rc;
                }
                        
-               *bsi->bsi_e = *e;
-               free( e );
                goto done;
        }
 
index ff2b3574a80478496caf2eb9aa283a0d397b0f6d..fcf6cb02a42234cf809aeddf4b7367ad4d7cb99c 100644 (file)
@@ -936,17 +936,22 @@ int entry_decode(EntryHeader *eh, Entry **e)
        return 0;
 }
 
+int entry_dup_to( Entry *source, Entry *dest )
+{
+       dest->e_id = source->e_id;
+       ber_dupbv( &dest->e_name, &source->e_name );
+       ber_dupbv( &dest->e_nname, &source->e_nname );
+       dest->e_attrs = attrs_dup( source->e_attrs );
+       dest->e_ocflags = source->e_ocflags;
+       return LDAP_SUCCESS;
+}
+
 Entry *entry_dup( Entry *e )
 {
        Entry *ret;
 
        ret = entry_alloc();
-
-       ret->e_id = e->e_id;
-       ber_dupbv( &ret->e_name, &e->e_name );
-       ber_dupbv( &ret->e_nname, &e->e_nname );
-       ret->e_attrs = attrs_dup( e->e_attrs );
-       ret->e_ocflags = e->e_ocflags;
+       entry_dup_to(e, ret);
 
        return ret;
 }
index 6e962d2ebb3cd6cebe388cfd48ab9948ffa71dc2..f9cb9e9ac73ab34dda23483826004b995ffa1efe 100644 (file)
@@ -991,6 +991,7 @@ LDAP_SLAPD_F (int) entry_cmp LDAP_P(( Entry *a, Entry *b ));
 LDAP_SLAPD_F (int) entry_dn_cmp LDAP_P(( const void *v_a, const void *v_b ));
 LDAP_SLAPD_F (int) entry_id_cmp LDAP_P(( const void *v_a, const void *v_b ));
 LDAP_SLAPD_F (Entry *) entry_dup LDAP_P(( Entry *e ));
+LDAP_SLAPD_F (int) entry_dup_to LDAP_P(( Entry *src, Entry *dest ));
 LDAP_SLAPD_F (Entry *) entry_dup_bv LDAP_P(( Entry *e ));
 LDAP_SLAPD_F (Entry *) entry_alloc LDAP_P((void));
 LDAP_SLAPD_F (int) entry_prealloc LDAP_P((int num));