diff src/stdlib/SDL_getenv.c @ 1341:d02b552e5304

Configure dynamically generates SDL_config.h I'm still wrestling with autoheader, but this should work for now... Fixed lots of build problems with C library support disabled
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 12:11:33 +0000
parents 3692456e7b0f
children 22f39393668a
line wrap: on
line diff
--- a/src/stdlib/SDL_getenv.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/stdlib/SDL_getenv.c	Tue Feb 07 12:11:33 2006 +0000
@@ -113,11 +113,11 @@
 	}
 
 	/* Allocate memory for the variable */
-	new_variable = (char *)malloc(strlen(variable)+1);
+	new_variable = (char *)SDL_malloc(SDL_strlen(variable)+1);
 	if ( ! new_variable ) {
 		return(-1);
 	}
-	strcpy(new_variable, variable);
+	SDL_strcpy(new_variable, variable);
 
 	/* Actually put it into the environment */
 	added = 0;
@@ -126,13 +126,13 @@
 		/* Check to see if it's already there... */
 		len = (value - name);
 		for ( ; SDL_env[i]; ++i ) {
-			if ( strncmp(SDL_env[i], name, len) == 0 ) {
+			if ( SDL_strncmp(SDL_env[i], name, len) == 0 ) {
 				break;
 			}
 		}
 		/* If we found it, just replace the entry */
 		if ( SDL_env[i] ) {
-			free(SDL_env[i]);
+			SDL_free(SDL_env[i]);
 			SDL_env[i] = new_variable;
 			added = 1;
 		}
@@ -147,7 +147,7 @@
 			SDL_env[i++] = (char *)0;
 			added = 1;
 		} else {
-			free(new_variable);
+			SDL_free(new_variable);
 		}
 	}
 	return (added ? 0 : -1);
@@ -161,9 +161,9 @@
 
 	value = (char *)0;
 	if ( SDL_env ) {
-		len = strlen(name);
+		len = SDL_strlen(name);
 		for ( i=0; SDL_env[i] && !value; ++i ) {
-			if ( (strncmp(SDL_env[i], name, len) == 0) &&
+			if ( (SDL_strncmp(SDL_env[i], name, len) == 0) &&
 			     (SDL_env[i][len] == '=') ) {
 				value = &SDL_env[i][len+1];
 			}
@@ -185,59 +185,59 @@
 
 	printf("Checking for non-existent variable... ");
 	fflush(stdout);
-	if ( ! getenv("EXISTS") ) {
+	if ( ! SDL_getenv("EXISTS") ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");
 	}
 	printf("Setting FIRST=VALUE1 in the environment... ");
 	fflush(stdout);
-	if ( putenv("FIRST=VALUE1") == 0 ) {
+	if ( SDL_putenv("FIRST=VALUE1") == 0 ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");
 	}
 	printf("Getting FIRST from the environment... ");
 	fflush(stdout);
-	value = getenv("FIRST");
-	if ( value && (strcmp(value, "VALUE1") == 0) ) {
+	value = SDL_getenv("FIRST");
+	if ( value && (SDL_strcmp(value, "VALUE1") == 0) ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");
 	}
 	printf("Setting SECOND=VALUE2 in the environment... ");
 	fflush(stdout);
-	if ( putenv("SECOND=VALUE2") == 0 ) {
+	if ( SDL_putenv("SECOND=VALUE2") == 0 ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");
 	}
 	printf("Getting SECOND from the environment... ");
 	fflush(stdout);
-	value = getenv("SECOND");
-	if ( value && (strcmp(value, "VALUE2") == 0) ) {
+	value = SDL_getenv("SECOND");
+	if ( value && (SDL_strcmp(value, "VALUE2") == 0) ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");
 	}
 	printf("Setting FIRST=NOVALUE in the environment... ");
 	fflush(stdout);
-	if ( putenv("FIRST=NOVALUE") == 0 ) {
+	if ( SDL_putenv("FIRST=NOVALUE") == 0 ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");
 	}
 	printf("Getting FIRST from the environment... ");
 	fflush(stdout);
-	value = getenv("FIRST");
-	if ( value && (strcmp(value, "NOVALUE") == 0) ) {
+	value = SDL_getenv("FIRST");
+	if ( value && (SDL_strcmp(value, "NOVALUE") == 0) ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");
 	}
 	printf("Checking for non-existent variable... ");
 	fflush(stdout);
-	if ( ! getenv("EXISTS") ) {
+	if ( ! SDL_getenv("EXISTS") ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");