]> git.sur5r.net Git - openldap/commitdiff
ITS#6080 again: simplify ber_strnlen, don't use strnlen, revert _GNU_SOURCE
authorHallvard Furuseth <hallvard@openldap.org>
Fri, 1 May 2009 03:10:25 +0000 (03:10 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Fri, 1 May 2009 03:10:25 +0000 (03:10 +0000)
libraries/liblber/memory.c

index 74261240c3b63a9d855ef5cd5fa3a028fa11de71..284cd04b8ebc66951801ad7a1d67ac9144ca0c4d 100644 (file)
  * <http://www.OpenLDAP.org/license.html>.
  */
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE 1  /* Needed for <string.h> if HAVE_STRNLEN */
-#endif
-
 #include "portable.h"
 
 #include <ac/stdlib.h>
@@ -658,19 +654,11 @@ ber_strdup( LDAP_CONST char *s )
 ber_len_t
 ber_strnlen( LDAP_CONST char *s, ber_len_t len )
 {
-#ifdef HAVE_STRNLEN
-       return (ber_len_t)strnlen( s, (ber_len_t)len );
-#else
        ber_len_t l;
 
-       for ( l = 0; l < len; l++ ) {
-               if ( s[l] == '\0' ) {
-                       return l;
-               }
-       }
+       for ( l = 0; l < len && s[l] != '\0'; l++ ) ;
 
-       return len;
-#endif /* HAVE_STRNLEN */
+       return l;
 }
 
 char *