src/stdlib/SDL_getenv.c
changeset 1456 84de7511f79f
parent 1433 bb6839704ed6
child 1472 4aac8563c296
equal deleted inserted replaced
1455:f487bb150acc 1456:84de7511f79f
    31 #include <windows.h>
    31 #include <windows.h>
    32 
    32 
    33 /* Note this isn't thread-safe! */
    33 /* Note this isn't thread-safe! */
    34 
    34 
    35 static char *SDL_envmem = NULL;	/* Ugh, memory leak */
    35 static char *SDL_envmem = NULL;	/* Ugh, memory leak */
    36 static DWORD SDL_envmemlen = 0;
    36 static size_t SDL_envmemlen = 0;
    37 
    37 
    38 /* Put a variable of the form "name=value" into the environment */
    38 /* Put a variable of the form "name=value" into the environment */
    39 int SDL_putenv(const char *variable)
    39 int SDL_putenv(const char *variable)
    40 {
    40 {
    41 	DWORD bufferlen;
    41 	size_t bufferlen;
    42 	char *value;
    42 	char *value;
    43 	const char *sep;
    43 	const char *sep;
    44 
    44 
    45 	sep = SDL_strchr(variable, '=');
    45 	sep = SDL_strchr(variable, '=');
    46 	if ( sep == NULL ) {
    46 	if ( sep == NULL ) {
    65 }
    65 }
    66 
    66 
    67 /* Retrieve a variable named "name" from the environment */
    67 /* Retrieve a variable named "name" from the environment */
    68 char *SDL_getenv(const char *name)
    68 char *SDL_getenv(const char *name)
    69 {
    69 {
    70 	DWORD bufferlen;
    70 	size_t bufferlen;
    71 
    71 
    72 	bufferlen = GetEnvironmentVariable(name, SDL_envmem, SDL_envmemlen);
    72 	bufferlen = GetEnvironmentVariable(name, SDL_envmem, SDL_envmemlen);
    73 	if ( bufferlen == 0 ) {
    73 	if ( bufferlen == 0 ) {
    74 		return NULL;
    74 		return NULL;
    75 	}
    75 	}