Mercurial > sdl-ios-xcode
comparison src/stdlib/SDL_getenv.c @ 1336:3692456e7b0f
Use SDL_ prefixed versions of C library functions.
FIXME:
Change #include <stdlib.h> to #include "SDL_stdlib.h"
Change #include <string.h> to #include "SDL_string.h"
Make sure nothing else broke because of this...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 07 Feb 2006 06:59:48 +0000 |
parents | 1cbaeee565b1 |
children | d02b552e5304 |
comparison
equal
deleted
inserted
replaced
1335:c39265384763 | 1336:3692456e7b0f |
---|---|
40 { | 40 { |
41 DWORD bufferlen; | 41 DWORD bufferlen; |
42 char *value; | 42 char *value; |
43 const char *sep; | 43 const char *sep; |
44 | 44 |
45 sep = strchr(variable, '='); | 45 sep = SDL_strchr(variable, '='); |
46 if ( sep == NULL ) { | 46 if ( sep == NULL ) { |
47 return -1; | 47 return -1; |
48 } | 48 } |
49 bufferlen = strlen(variable)+1; | 49 bufferlen = SDL_strlen(variable)+1; |
50 if ( bufferlen > SDL_envmemlen ) { | 50 if ( bufferlen > SDL_envmemlen ) { |
51 char *newmem = (char *)realloc(SDL_envmem, bufferlen); | 51 char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen); |
52 if ( newmem == NULL ) { | 52 if ( newmem == NULL ) { |
53 return -1; | 53 return -1; |
54 } | 54 } |
55 SDL_envmem = newmem; | 55 SDL_envmem = newmem; |
56 SDL_envmemlen = bufferlen; | 56 SDL_envmemlen = bufferlen; |
57 } | 57 } |
58 strcpy(SDL_envmem, variable); | 58 SDL_strcpy(SDL_envmem, variable); |
59 value = SDL_envmem + (sep - variable); | 59 value = SDL_envmem + (sep - variable); |
60 *value++ = '\0'; | 60 *value++ = '\0'; |
61 if ( !SetEnvironmentVariable(SDL_envmem, *value ? value : NULL) ) { | 61 if ( !SetEnvironmentVariable(SDL_envmem, *value ? value : NULL) ) { |
62 return -1; | 62 return -1; |
63 } | 63 } |
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 } |
76 if ( bufferlen > SDL_envmemlen ) { | 76 if ( bufferlen > SDL_envmemlen ) { |
77 char *newmem = (char *)realloc(SDL_envmem, bufferlen); | 77 char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen); |
78 if ( newmem == NULL ) { | 78 if ( newmem == NULL ) { |
79 return NULL; | 79 return NULL; |
80 } | 80 } |
81 SDL_envmem = newmem; | 81 SDL_envmem = newmem; |
82 SDL_envmemlen = bufferlen; | 82 SDL_envmemlen = bufferlen; |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 /* Didn't find it in the environment, expand and add */ | 141 /* Didn't find it in the environment, expand and add */ |
142 if ( ! added ) { | 142 if ( ! added ) { |
143 new_env = realloc(SDL_env, (i+2)*sizeof(char *)); | 143 new_env = SDL_realloc(SDL_env, (i+2)*sizeof(char *)); |
144 if ( new_env ) { | 144 if ( new_env ) { |
145 SDL_env = new_env; | 145 SDL_env = new_env; |
146 SDL_env[i++] = new_variable; | 146 SDL_env[i++] = new_variable; |
147 SDL_env[i++] = (char *)0; | 147 SDL_env[i++] = (char *)0; |
148 added = 1; | 148 added = 1; |