Mercurial > sdl-ios-xcode
comparison src/cdrom/beos/SDL_syscdrom.cc @ 1572:3a8920cc822b
*** empty log message ***
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 21 Mar 2006 16:04:44 +0000 |
parents | 376665398b25 |
children | 92947e3a18db |
comparison
equal
deleted
inserted
replaced
1571:0160eb7cccee | 1572:3a8920cc822b |
---|---|
107 | 107 |
108 /* Add a CD-ROM drive to our list of valid drives */ | 108 /* Add a CD-ROM drive to our list of valid drives */ |
109 static void AddDrive(char *drive) | 109 static void AddDrive(char *drive) |
110 { | 110 { |
111 int i; | 111 int i; |
112 size_t len; | |
112 | 113 |
113 if ( SDL_numcds < MAX_DRIVES ) { | 114 if ( SDL_numcds < MAX_DRIVES ) { |
114 /* Add this drive to our list */ | 115 /* Add this drive to our list */ |
115 i = SDL_numcds; | 116 i = SDL_numcds; |
116 SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); | 117 len = SDL_strlen(drive)+1; |
118 SDL_cdlist[i] = (char *)SDL_malloc(len); | |
117 if ( SDL_cdlist[i] == NULL ) { | 119 if ( SDL_cdlist[i] == NULL ) { |
118 SDL_OutOfMemory(); | 120 SDL_OutOfMemory(); |
119 return; | 121 return; |
120 } | 122 } |
121 SDL_strcpy(SDL_cdlist[i], drive); | 123 SDL_strlcpy(SDL_cdlist[i], drive, len); |
122 ++SDL_numcds; | 124 ++SDL_numcds; |
123 #ifdef CDROM_DEBUG | 125 #ifdef CDROM_DEBUG |
124 fprintf(stderr, "Added CD-ROM drive: %s\n", drive); | 126 fprintf(stderr, "Added CD-ROM drive: %s\n", drive); |
125 #endif | 127 #endif |
126 } | 128 } |
163 | 165 |
164 /* Look in the environment for our CD-ROM drive list */ | 166 /* Look in the environment for our CD-ROM drive list */ |
165 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ | 167 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ |
166 if ( SDLcdrom != NULL ) { | 168 if ( SDLcdrom != NULL ) { |
167 char *cdpath, *delim; | 169 char *cdpath, *delim; |
168 cdpath = (char *)SDL_malloc(SDL_strlen(SDLcdrom)+1); | 170 size_t len = SDL_strlen(SDLcdrom)+1; |
171 cdpath = SDL_stack_alloc(char, len); | |
169 if ( cdpath != NULL ) { | 172 if ( cdpath != NULL ) { |
170 SDL_strcpy(cdpath, SDLcdrom); | 173 SDL_strlcpy(cdpath, SDLcdrom, len); |
171 SDLcdrom = cdpath; | 174 SDLcdrom = cdpath; |
172 do { | 175 do { |
173 delim = SDL_strchr(SDLcdrom, ':'); | 176 delim = SDL_strchr(SDLcdrom, ':'); |
174 if ( delim ) { | 177 if ( delim ) { |
175 *delim++ = '\0'; | 178 *delim++ = '\0'; |
181 SDLcdrom = delim; | 184 SDLcdrom = delim; |
182 } else { | 185 } else { |
183 SDLcdrom = NULL; | 186 SDLcdrom = NULL; |
184 } | 187 } |
185 } while ( SDLcdrom ); | 188 } while ( SDLcdrom ); |
186 SDL_free(cdpath); | 189 SDL_stack_free(cdpath); |
187 } | 190 } |
188 | 191 |
189 /* If we found our drives, there's nothing left to do */ | 192 /* If we found our drives, there's nothing left to do */ |
190 if ( SDL_numcds > 0 ) { | 193 if ( SDL_numcds > 0 ) { |
191 return(0); | 194 return(0); |