X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fdsparse.c;h=fd6be6baa47a350ab5c869ca08dd026488e11272;hb=f84c43a43be094d89e534184fddf61010a4d61f6;hp=3fdd7b9c44a3cbfc8265449890ea40ebdb19d0cd;hpb=702109706b76fea49bde29d6351b2aaa4ee0e7fa;p=openldap diff --git a/libraries/libldap/dsparse.c b/libraries/libldap/dsparse.c index 3fdd7b9c44..fd6be6baa4 100644 --- a/libraries/libldap/dsparse.c +++ b/libraries/libldap/dsparse.c @@ -1,4 +1,9 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1993, 1994 Regents of the University of Michigan. * All rights reserved. * @@ -18,7 +23,7 @@ #include "portable.h" #include -#include +#include #include #include @@ -30,15 +35,13 @@ #include "ldap-int.h" -int next_line_tokens LDAP_P(( char **bufp, long *blenp, char ***toksp )); -void free_strarray LDAP_P(( char **sap )); -static int next_line LDAP_P(( char **bufp, long *blenp, char **linep )); +static int next_line LDAP_P(( char **bufp, ber_len_t *blenp, char **linep )); static char *next_token LDAP_P(( char ** sp )); int -next_line_tokens( char **bufp, long *blenp, char ***toksp ) +next_line_tokens( char **bufp, ber_len_t *blenp, char ***toksp ) { char *p, *line, *token, **toks; int rc, tokcnt; @@ -49,18 +52,18 @@ next_line_tokens( char **bufp, long *blenp, char ***toksp ) return( rc ); } - if (( toks = (char **)calloc( 1, sizeof( char * ))) == NULL ) { - free( line ); + if (( toks = (char **)LDAP_CALLOC( 1, sizeof( char * ))) == NULL ) { + LBER_FREE( line ); return( -1 ); } tokcnt = 0; p = line; while (( token = next_token( &p )) != NULL ) { - if (( toks = (char **)realloc( toks, ( tokcnt + 2 ) * + if (( toks = (char **)LDAP_REALLOC( toks, ( tokcnt + 2 ) * sizeof( char * ))) == NULL ) { - free( (char *)toks ); - free( line ); + LBER_FREE( (char *)toks ); + LBER_FREE( line ); return( -1 ); } toks[ tokcnt ] = token; @@ -73,11 +76,11 @@ next_line_tokens( char **bufp, long *blenp, char ***toksp ) toks = NULL; } - free( line ); + LBER_FREE( line ); if ( tokcnt == 0 ) { if ( toks != NULL ) { - free( (char *)toks ); + LBER_FREE( (char *)toks ); } } else { *toksp = toks; @@ -88,10 +91,10 @@ next_line_tokens( char **bufp, long *blenp, char ***toksp ) static int -next_line( char **bufp, long *blenp, char **linep ) +next_line( char **bufp, ber_len_t *blenp, char **linep ) { char *linestart, *line, *p; - long plen; + ber_slen_t plen; linestart = *bufp; p = *bufp; @@ -129,7 +132,7 @@ next_line( char **bufp, long *blenp, char **linep ) return( 0 ); /* end of file */ } - if (( line = malloc( p - linestart )) == NULL ) { + if (( line = LDAP_MALLOC( p - linestart )) == NULL ) { *linep = NULL; return( -1 ); /* fatal error */ } @@ -153,7 +156,7 @@ next_token( char **sp ) p = *sp; - while ( isspace( *p )) { /* skip leading white space */ + while ( isspace( (unsigned char) *p )) { /* skip leading white space */ ++p; } @@ -168,7 +171,7 @@ next_token( char **sp ) t = tokstart = p; for ( ;; ) { - if ( *p == '\0' || ( isspace( *p ) && !in_quote )) { + if ( *p == '\0' || ( isspace( (unsigned char) *p ) && !in_quote )) { if ( *p != '\0' ) { ++p; } @@ -190,7 +193,7 @@ next_token( char **sp ) return( NULL ); } - return( strdup( tokstart )); + return( LDAP_STRDUP( tokstart )); } @@ -201,8 +204,8 @@ free_strarray( char **sap ) if ( sap != NULL ) { for ( i = 0; sap[ i ] != NULL; ++i ) { - free( sap[ i ] ); + LBER_FREE( sap[ i ] ); } - free( (char *)sap ); + LBER_FREE( (char *)sap ); } }