]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/friendly.c
Don't assert on null
[openldap] / libraries / libldap / friendly.c
index 12896aad8370b9d75aa497100f91de6ad0a6a313..5d4abdabbe22cd60700352bcbbd3ca7b11095c03 100644 (file)
@@ -1,4 +1,9 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
@@ -7,14 +12,9 @@
 
 #include "portable.h"
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
 #include <stdio.h>
-#include <stdlib.h>
+#include <ac/stdlib.h>
 
-#include <ac/ctype.h>
 #include <ac/errno.h>
 #include <ac/socket.h>
 #include <ac/string.h>
@@ -23,7 +23,10 @@ static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of
 #include "ldap-int.h"
 
 char *
-ldap_friendly_name( char *filename, char *uname, FriendlyMap **map )
+ldap_friendly_name(
+       LDAP_CONST char *filename,
+       /* LDAP_CONST */ char *uname,
+       LDAPFriendlyMap **map )
 {
        int     i, entries;
        FILE    *fp;
@@ -46,8 +49,8 @@ ldap_friendly_name( char *filename, char *uname, FriendlyMap **map )
                }
                rewind( fp );
 
-               if ( (*map = (FriendlyMap *) malloc( (entries + 1) *
-                   sizeof(FriendlyMap) )) == NULL ) {
+               if ( (*map = (LDAPFriendlyMap *) LDAP_MALLOC( (entries + 1) *
+                   sizeof(LDAPFriendlyMap) )) == NULL ) {
                        fclose( fp );
                        return( uname );
                }
@@ -83,37 +86,37 @@ ldap_friendly_name( char *filename, char *uname, FriendlyMap **map )
                                }
                        }
 
-                       (*map)[i].f_unfriendly = strdup( buf );
-                       (*map)[i].f_friendly = strdup( s );
+                       (*map)[i].lf_unfriendly = LDAP_STRDUP( buf );
+                       (*map)[i].lf_friendly   = LDAP_STRDUP( s );
                        i++;
                }
 
                fclose( fp );
-               (*map)[i].f_unfriendly = NULL;
+               (*map)[i].lf_unfriendly = NULL;
        }
 
-       for ( i = 0; (*map)[i].f_unfriendly != NULL; i++ ) {
-               if ( strcasecmp( uname, (*map)[i].f_unfriendly ) == 0 )
-                       return( (*map)[i].f_friendly );
+       for ( i = 0; (*map)[i].lf_unfriendly != NULL; i++ ) {
+               if ( strcasecmp( uname, (*map)[i].lf_unfriendly ) == 0 )
+                       return( (*map)[i].lf_friendly );
        }
        return( uname );
 }
 
 
 void
-ldap_free_friendlymap( FriendlyMap **map )
+ldap_free_friendlymap( LDAPFriendlyMap **map )
 {
-       struct friendly* pF = *map;
+       LDAPFriendlyMap* pF = *map;
 
        if ( pF == NULL )
                return;
 
-       while ( pF->f_unfriendly )
+       while ( pF->lf_unfriendly )
        {
-               free( pF->f_unfriendly );
-               free( pF->f_friendly );
+               LDAP_FREE( pF->lf_unfriendly );
+               LDAP_FREE( pF->lf_friendly );
                pF++;
        }
-       free( *map );
+       LDAP_FREE( *map );
        *map = NULL;
 }