src/stdlib/SDL_getenv.c
changeset 1341 d02b552e5304
parent 1336 3692456e7b0f
child 1354 22f39393668a
     1.1 --- a/src/stdlib/SDL_getenv.c	Tue Feb 07 11:18:21 2006 +0000
     1.2 +++ b/src/stdlib/SDL_getenv.c	Tue Feb 07 12:11:33 2006 +0000
     1.3 @@ -113,11 +113,11 @@
     1.4  	}
     1.5  
     1.6  	/* Allocate memory for the variable */
     1.7 -	new_variable = (char *)malloc(strlen(variable)+1);
     1.8 +	new_variable = (char *)SDL_malloc(SDL_strlen(variable)+1);
     1.9  	if ( ! new_variable ) {
    1.10  		return(-1);
    1.11  	}
    1.12 -	strcpy(new_variable, variable);
    1.13 +	SDL_strcpy(new_variable, variable);
    1.14  
    1.15  	/* Actually put it into the environment */
    1.16  	added = 0;
    1.17 @@ -126,13 +126,13 @@
    1.18  		/* Check to see if it's already there... */
    1.19  		len = (value - name);
    1.20  		for ( ; SDL_env[i]; ++i ) {
    1.21 -			if ( strncmp(SDL_env[i], name, len) == 0 ) {
    1.22 +			if ( SDL_strncmp(SDL_env[i], name, len) == 0 ) {
    1.23  				break;
    1.24  			}
    1.25  		}
    1.26  		/* If we found it, just replace the entry */
    1.27  		if ( SDL_env[i] ) {
    1.28 -			free(SDL_env[i]);
    1.29 +			SDL_free(SDL_env[i]);
    1.30  			SDL_env[i] = new_variable;
    1.31  			added = 1;
    1.32  		}
    1.33 @@ -147,7 +147,7 @@
    1.34  			SDL_env[i++] = (char *)0;
    1.35  			added = 1;
    1.36  		} else {
    1.37 -			free(new_variable);
    1.38 +			SDL_free(new_variable);
    1.39  		}
    1.40  	}
    1.41  	return (added ? 0 : -1);
    1.42 @@ -161,9 +161,9 @@
    1.43  
    1.44  	value = (char *)0;
    1.45  	if ( SDL_env ) {
    1.46 -		len = strlen(name);
    1.47 +		len = SDL_strlen(name);
    1.48  		for ( i=0; SDL_env[i] && !value; ++i ) {
    1.49 -			if ( (strncmp(SDL_env[i], name, len) == 0) &&
    1.50 +			if ( (SDL_strncmp(SDL_env[i], name, len) == 0) &&
    1.51  			     (SDL_env[i][len] == '=') ) {
    1.52  				value = &SDL_env[i][len+1];
    1.53  			}
    1.54 @@ -185,59 +185,59 @@
    1.55  
    1.56  	printf("Checking for non-existent variable... ");
    1.57  	fflush(stdout);
    1.58 -	if ( ! getenv("EXISTS") ) {
    1.59 +	if ( ! SDL_getenv("EXISTS") ) {
    1.60  		printf("okay\n");
    1.61  	} else {
    1.62  		printf("failed\n");
    1.63  	}
    1.64  	printf("Setting FIRST=VALUE1 in the environment... ");
    1.65  	fflush(stdout);
    1.66 -	if ( putenv("FIRST=VALUE1") == 0 ) {
    1.67 +	if ( SDL_putenv("FIRST=VALUE1") == 0 ) {
    1.68  		printf("okay\n");
    1.69  	} else {
    1.70  		printf("failed\n");
    1.71  	}
    1.72  	printf("Getting FIRST from the environment... ");
    1.73  	fflush(stdout);
    1.74 -	value = getenv("FIRST");
    1.75 -	if ( value && (strcmp(value, "VALUE1") == 0) ) {
    1.76 +	value = SDL_getenv("FIRST");
    1.77 +	if ( value && (SDL_strcmp(value, "VALUE1") == 0) ) {
    1.78  		printf("okay\n");
    1.79  	} else {
    1.80  		printf("failed\n");
    1.81  	}
    1.82  	printf("Setting SECOND=VALUE2 in the environment... ");
    1.83  	fflush(stdout);
    1.84 -	if ( putenv("SECOND=VALUE2") == 0 ) {
    1.85 +	if ( SDL_putenv("SECOND=VALUE2") == 0 ) {
    1.86  		printf("okay\n");
    1.87  	} else {
    1.88  		printf("failed\n");
    1.89  	}
    1.90  	printf("Getting SECOND from the environment... ");
    1.91  	fflush(stdout);
    1.92 -	value = getenv("SECOND");
    1.93 -	if ( value && (strcmp(value, "VALUE2") == 0) ) {
    1.94 +	value = SDL_getenv("SECOND");
    1.95 +	if ( value && (SDL_strcmp(value, "VALUE2") == 0) ) {
    1.96  		printf("okay\n");
    1.97  	} else {
    1.98  		printf("failed\n");
    1.99  	}
   1.100  	printf("Setting FIRST=NOVALUE in the environment... ");
   1.101  	fflush(stdout);
   1.102 -	if ( putenv("FIRST=NOVALUE") == 0 ) {
   1.103 +	if ( SDL_putenv("FIRST=NOVALUE") == 0 ) {
   1.104  		printf("okay\n");
   1.105  	} else {
   1.106  		printf("failed\n");
   1.107  	}
   1.108  	printf("Getting FIRST from the environment... ");
   1.109  	fflush(stdout);
   1.110 -	value = getenv("FIRST");
   1.111 -	if ( value && (strcmp(value, "NOVALUE") == 0) ) {
   1.112 +	value = SDL_getenv("FIRST");
   1.113 +	if ( value && (SDL_strcmp(value, "NOVALUE") == 0) ) {
   1.114  		printf("okay\n");
   1.115  	} else {
   1.116  		printf("failed\n");
   1.117  	}
   1.118  	printf("Checking for non-existent variable... ");
   1.119  	fflush(stdout);
   1.120 -	if ( ! getenv("EXISTS") ) {
   1.121 +	if ( ! SDL_getenv("EXISTS") ) {
   1.122  		printf("okay\n");
   1.123  	} else {
   1.124  		printf("failed\n");