changeset 1572:3a8920cc822b

*** empty log message ***
author Sam Lantinga <slouken@libsdl.org>
date Tue, 21 Mar 2006 16:04:44 +0000
parents 0160eb7cccee
children 2422ca15ba42
files src/cdrom/beos/SDL_syscdrom.cc src/main/macosx/SDLMain.m src/video/bwindow/SDL_sysvideo.cc
diffstat 3 files changed, 17 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/cdrom/beos/SDL_syscdrom.cc	Tue Mar 21 10:38:41 2006 +0000
+++ b/src/cdrom/beos/SDL_syscdrom.cc	Tue Mar 21 16:04:44 2006 +0000
@@ -109,16 +109,18 @@
 static void AddDrive(char *drive)
 {
 	int i;
+	size_t len;
 
 	if ( SDL_numcds < MAX_DRIVES ) {
 		/* Add this drive to our list */
 		i = SDL_numcds;
-		SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
+		len = SDL_strlen(drive)+1;
+		SDL_cdlist[i] = (char *)SDL_malloc(len);
 		if ( SDL_cdlist[i] == NULL ) {
 			SDL_OutOfMemory();
 			return;
 		}
-		SDL_strcpy(SDL_cdlist[i], drive);
+		SDL_strlcpy(SDL_cdlist[i], drive, len);
 		++SDL_numcds;
 #ifdef CDROM_DEBUG
   fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
@@ -165,9 +167,10 @@
 	SDLcdrom = SDL_getenv("SDL_CDROM");	/* ':' separated list of devices */
 	if ( SDLcdrom != NULL ) {
 		char *cdpath, *delim;
-		cdpath = (char *)SDL_malloc(SDL_strlen(SDLcdrom)+1);
+		size_t len = SDL_strlen(SDLcdrom)+1;
+		cdpath = SDL_stack_alloc(char, len);
 		if ( cdpath != NULL ) {
-			SDL_strcpy(cdpath, SDLcdrom);
+			SDL_strlcpy(cdpath, SDLcdrom, len);
 			SDLcdrom = cdpath;
 			do {
 				delim = SDL_strchr(SDLcdrom, ':');
@@ -183,7 +186,7 @@
 					SDLcdrom = NULL;
 				}
 			} while ( SDLcdrom );
-			SDL_free(cdpath);
+			SDL_stack_free(cdpath);
 		}
 
 		/* If we found our drives, there's nothing left to do */
--- a/src/main/macosx/SDLMain.m	Tue Mar 21 10:38:41 2006 +0000
+++ b/src/main/macosx/SDLMain.m	Tue Mar 21 16:04:44 2006 +0000
@@ -252,19 +252,20 @@
         return FALSE;
 
     const char *temparg = [filename UTF8String];
-    char *arg = (char *) malloc(strlen(temparg) + 1);
+    size_t arglen = SDL_strlen(temparg) + 1;
+    char *arg = (char *) SDL_malloc(arglen);
     if (arg == NULL)
         return FALSE;
 
     char **newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
     if (newargv == NULL)
     {
-        free(arg);
+        SDL_free(arg);
         return FALSE;
     }
     gArgv = newargv;
 
-    strcpy(arg, temparg);
+    SDL_strlcpy(arg, temparg, arglen);
     gArgv[gArgc++] = arg;
     gArgv[gArgc] = NULL;
     return TRUE;
@@ -346,7 +347,7 @@
     /* Copy the arguments into a global variable */
     /* This is passed if we are launched by double-clicking */
     if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
-        gArgv = (char **) malloc(sizeof (char *) * 2);
+        gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
         gArgv[0] = argv[0];
         gArgv[1] = NULL;
         gArgc = 1;
@@ -354,7 +355,7 @@
     } else {
         int i;
         gArgc = argc;
-        gArgv = (char **) malloc(sizeof (char *) * (argc+1));
+        gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
         for (i = 0; i <= argc; i++)
             gArgv[i] = argv[i];
         gFinderLaunch = NO;
--- a/src/video/bwindow/SDL_sysvideo.cc	Tue Mar 21 10:38:41 2006 +0000
+++ b/src/video/bwindow/SDL_sysvideo.cc	Tue Mar 21 16:04:44 2006 +0000
@@ -639,7 +639,7 @@
 				if (get_image_symbol((image_id)cookie,"glBegin",B_SYMBOL_TYPE_ANY,&location) == B_OK) {
 					_this->gl_config.dll_handle = (void*)cookie;
 					_this->gl_config.driver_loaded = 1;
-					SDL_strncpy(_this->gl_config.driver_path, "libGL.so", sizeof(_this->gl_config.driver_path)-1);
+					SDL_strlcpy(_this->gl_config.driver_path, "libGL.so", SDL_arraysize(_this->gl_config.driver_path));
 				}
 			}
 		}
@@ -667,7 +667,7 @@
 
 		if ((_this->gl_config.dll_handle = (void*)load_add_on(path)) != (void*)B_ERROR) {
 			_this->gl_config.driver_loaded = 1;
-			SDL_strncpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path)-1);
+			SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path));
 		}*/
 	}
 
@@ -676,7 +676,7 @@
 	} else {
 		_this->gl_config.dll_handle = NULL;
 		_this->gl_config.driver_loaded = 0;
-		SDL_strcpy(_this->gl_config.driver_path, "");
+		*_this->gl_config.driver_path = '\0';
 		return -1;
 	}
 }