]> git.sur5r.net Git - openldap/commitdiff
Code which doesn't hanlding allocation failure should use
authorKurt Zeilenga <kurt@openldap.org>
Thu, 6 Apr 2006 21:44:05 +0000 (21:44 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 6 Apr 2006 21:44:05 +0000 (21:44 +0000)
ch_ routines, not SLAP_ macros

servers/slapd/back-ldif/ldif.c
servers/slapd/referral.c
servers/slapd/result.c

index ba40fba235112dc1e1ae796fe0e9d913f2619f12..5c662962bd38349e10476fa4ad7a0b2dfa5b9916 100644 (file)
@@ -354,11 +354,11 @@ static int r_enum_tree(enumCookie *ck, struct berval *path,
                } else {
                /* Queueing up for tool mode */
                        if(ck->entries == NULL) {
-                               ck->entries = (Entry **) SLAP_MALLOC(sizeof(Entry *) * ENTRY_BUFF_INCREMENT);
+                               ck->entries = (Entry **) ch_malloc(sizeof(Entry *) * ENTRY_BUFF_INCREMENT);
                                ck->elen = ENTRY_BUFF_INCREMENT;
                        }
                        if(ck->eind >= ck->elen) { /* grow entries if necessary */      
-                               ck->entries = (Entry **) SLAP_REALLOC(ck->entries, sizeof(Entry *) * (ck->elen) * 2);
+                               ck->entries = (Entry **) ch_realloc(ck->entries, sizeof(Entry *) * (ck->elen) * 2);
                                ck->elen *= 2;
                        }
 
index 4537420f3e54c55a82303a3ff8c30c0b9147c5f0..064854c721911b4b3d08af7e58fff6270097780f 100644 (file)
@@ -108,12 +108,7 @@ static char * referral_dn_muck(
                        }
 
                        muck.bv_len = ntargetDN.bv_len + nrefDN.bv_len - nbaseDN.bv_len;
-                       muck.bv_val = SLAP_MALLOC( muck.bv_len + 1 );
-                       if( muck.bv_val == NULL ) {
-                               Debug( LDAP_DEBUG_ANY,
-                                       "referral_dn_muck: SLAP_MALLOC failed\n", 0, 0, 0 );
-                               return NULL;
-                       }
+                       muck.bv_val = ch_malloc( muck.bv_len + 1 );
 
                        strncpy( muck.bv_val, ntargetDN.bv_val,
                                ntargetDN.bv_len-nbaseDN.bv_len );
@@ -217,12 +212,7 @@ BerVarray referral_rewrite(
                return NULL;
        }
 
-       refs = SLAP_MALLOC( ( i + 1 ) * sizeof( struct berval ) );
-       if ( refs == NULL ) {
-               Debug( LDAP_DEBUG_ANY,
-                       "referral_rewrite: SLAP_MALLOC failed\n", 0, 0, 0 );
-               return NULL;
-       }
+       refs = ch_malloc( ( i + 1 ) * sizeof( struct berval ) );
 
        for ( iv = in, jv = refs; !BER_BVISNULL( iv ); iv++ ) {
                LDAPURLDesc     *url;
@@ -292,12 +282,7 @@ BerVarray get_entry_referrals(
 
        if( i < 1 ) return NULL;
 
-       refs = SLAP_MALLOC( (i + 1) * sizeof(struct berval));
-       if( refs == NULL ) {
-               Debug( LDAP_DEBUG_ANY,
-                       "get_entry_referrals: SLAP_MALLOC failed\n", 0, 0, 0 );
-               return NULL;
-       }
+       refs = ch_malloc( (i + 1) * sizeof(struct berval));
 
        for( iv=attr->a_vals, jv=refs; iv->bv_val != NULL; iv++ ) {
                unsigned k;
index c82f8f651a6307135ede81557b076bc8e9e8c7eb..aefe3fac538cf73809cb12ac4cbd5444d440396a 100644 (file)
@@ -83,11 +83,7 @@ static char *v2ref( BerVarray ref, const char *text )
                }
        }
 
-       v2 = SLAP_MALLOC( len+i+sizeof("Referral:") );
-       if( v2 == NULL ) {
-               Debug( LDAP_DEBUG_ANY, "v2ref: SLAP_MALLOC failed", 0, 0, 0 );
-               return NULL;
-       }
+       v2 = ch_malloc( len+i+sizeof("Referral:") );
 
        if( text != NULL ) {
                strcpy(v2, text);
@@ -99,11 +95,7 @@ static char *v2ref( BerVarray ref, const char *text )
        len += sizeof("Referral:");
 
        for( i=0; ref[i].bv_val != NULL; i++ ) {
-               v2 = SLAP_REALLOC( v2, len + ref[i].bv_len + 1 );
-               if( v2 == NULL ) {
-                       Debug( LDAP_DEBUG_ANY, "v2ref: SLAP_MALLOC failed", 0, 0, 0 );
-                       return NULL;
-               }
+               v2 = ch_realloc( v2, len + ref[i].bv_len + 1 );
                v2[len-1] = '\n';
                AC_MEMCPY(&v2[len], ref[i].bv_val, ref[i].bv_len );
                len += ref[i].bv_len;