src/video/SDL_video.c
changeset 1336 3692456e7b0f
parent 1330 450721ad5436
child 1338 604d73db6802
     1.1 --- a/src/video/SDL_video.c	Mon Feb 06 17:28:04 2006 +0000
     1.2 +++ b/src/video/SDL_video.c	Tue Feb 07 06:59:48 2006 +0000
     1.3 @@ -175,13 +175,13 @@
     1.4  	video = NULL;
     1.5  	if ( driver_name != NULL ) {
     1.6  #if 0	/* This will be replaced with a better driver selection API */
     1.7 -		if ( strrchr(driver_name, ':') != NULL ) {
     1.8 -			index = atoi(strrchr(driver_name, ':')+1);
     1.9 +		if ( SDL_strrchr(driver_name, ':') != NULL ) {
    1.10 +			index = atoi(SDL_strrchr(driver_name, ':')+1);
    1.11  		}
    1.12  #endif
    1.13  		for ( i=0; bootstrap[i]; ++i ) {
    1.14 -			if ( strncmp(bootstrap[i]->name, driver_name,
    1.15 -			             strlen(bootstrap[i]->name)) == 0 ) {
    1.16 +			if ( SDL_strncmp(bootstrap[i]->name, driver_name,
    1.17 +			             SDL_strlen(bootstrap[i]->name)) == 0 ) {
    1.18  				if ( bootstrap[i]->available() ) {
    1.19  					video = bootstrap[i]->create(index);
    1.20  					break;
    1.21 @@ -216,7 +216,7 @@
    1.22  	video->wm_icon  = NULL;
    1.23  	video->offset_x = 0;
    1.24  	video->offset_y = 0;
    1.25 -	memset(&video->info, 0, (sizeof video->info));
    1.26 +	SDL_memset(&video->info, 0, (sizeof video->info));
    1.27  	
    1.28  	video->displayformatalphapixel = NULL;
    1.29  
    1.30 @@ -244,7 +244,7 @@
    1.31  	video->gl_config.multisamplesamples = 0;
    1.32  	
    1.33  	/* Initialize the video subsystem */
    1.34 -	memset(&vformat, 0, sizeof(vformat));
    1.35 +	SDL_memset(&vformat, 0, sizeof(vformat));
    1.36  	if ( video->VideoInit(video, &vformat) < 0 ) {
    1.37  		SDL_VideoQuit();
    1.38  		return(-1);
    1.39 @@ -289,7 +289,7 @@
    1.40  char *SDL_VideoDriverName(char *namebuf, int maxlen)
    1.41  {
    1.42  	if ( current_video != NULL ) {
    1.43 -		strncpy(namebuf, current_video->name, maxlen-1);
    1.44 +		SDL_strncpy(namebuf, current_video->name, maxlen-1);
    1.45  		namebuf[maxlen-1] = '\0';
    1.46  		return(namebuf);
    1.47  	}
    1.48 @@ -389,7 +389,7 @@
    1.49  	}
    1.50  
    1.51  	/* Search through the list valid of modes */
    1.52 -	memset(&format, 0, sizeof(format));
    1.53 +	SDL_memset(&format, 0, sizeof(format));
    1.54  	supported = 0;
    1.55  	table = ((bpp+7)/8)-1;
    1.56  	SDL_closest_depths[table][0] = bpp;
    1.57 @@ -461,7 +461,7 @@
    1.58  	}
    1.59  
    1.60  	/* No exact size match at any depth, look for closest match */
    1.61 -	memset(&format, 0, sizeof(format));
    1.62 +	SDL_memset(&format, 0, sizeof(format));
    1.63  	supported = 0;
    1.64  	table = ((*BitsPerPixel+7)/8)-1;
    1.65  	SDL_closest_depths[table][0] = *BitsPerPixel;
    1.66 @@ -541,7 +541,7 @@
    1.67  	if ( SDL_ShadowSurface->format->palette ) {
    1.68  		SDL_ShadowSurface->flags |= SDL_HWPALETTE;
    1.69  		if ( depth == (SDL_VideoSurface->format)->BitsPerPixel ) {
    1.70 -			memcpy(SDL_ShadowSurface->format->palette->colors,
    1.71 +			SDL_memcpy(SDL_ShadowSurface->format->palette->colors,
    1.72  				SDL_VideoSurface->format->palette->colors,
    1.73  				SDL_VideoSurface->format->palette->ncolors*
    1.74  							sizeof(SDL_Color));
    1.75 @@ -649,12 +649,12 @@
    1.76  		SDL_FreeSurface(ready_to_go);
    1.77  	}
    1.78  	if ( video->physpal ) {
    1.79 -		free(video->physpal->colors);
    1.80 -		free(video->physpal);
    1.81 +		SDL_free(video->physpal->colors);
    1.82 +		SDL_free(video->physpal);
    1.83  		video->physpal = NULL;
    1.84  	}
    1.85  	if( video->gammacols) {
    1.86 -		free(video->gammacols);
    1.87 +		SDL_free(video->gammacols);
    1.88  		video->gammacols = NULL;
    1.89  	}
    1.90  
    1.91 @@ -797,7 +797,7 @@
    1.92  		   support the GL_UNSIGNED_SHORT_5_6_5 texture format.
    1.93  		 */
    1.94  		if ( (bpp == 16) &&
    1.95 -		     (strstr((const char *)video->glGetString(GL_EXTENSIONS), "GL_EXT_packed_pixels") ||
    1.96 +		     (SDL_strstr((const char *)video->glGetString(GL_EXTENSIONS), "GL_EXT_packed_pixels") ||
    1.97  		     (atof((const char *)video->glGetString(GL_VERSION)) >= 1.2f))
    1.98  		   ) {
    1.99  			video->is_32bit = 0;
   1.100 @@ -843,7 +843,7 @@
   1.101  		SDL_FreeSurface(mode);
   1.102  
   1.103  		/* Set the surface completely opaque & white by default */
   1.104 -		memset( SDL_VideoSurface->pixels, 255, SDL_VideoSurface->h * SDL_VideoSurface->pitch );
   1.105 +		SDL_memset( SDL_VideoSurface->pixels, 255, SDL_VideoSurface->h * SDL_VideoSurface->pitch );
   1.106  		video->glGenTextures( 1, &video->texture );
   1.107  		video->glBindTexture( GL_TEXTURE_2D, video->texture );
   1.108  		video->glTexImage2D(
   1.109 @@ -1134,7 +1134,7 @@
   1.110  	SDL_Palette *vidpal;
   1.111  
   1.112  	if ( colors != (pal->colors + firstcolor) ) {
   1.113 -		memcpy(pal->colors + firstcolor, colors,
   1.114 +		SDL_memcpy(pal->colors + firstcolor, colors,
   1.115  		       ncolors * sizeof(*colors));
   1.116  	}
   1.117  
   1.118 @@ -1146,7 +1146,7 @@
   1.119  		 * changes to its logical palette so that
   1.120  		 * updates are always identity blits
   1.121  		 */
   1.122 -		memcpy(vidpal->colors + firstcolor, colors,
   1.123 +		SDL_memcpy(vidpal->colors + firstcolor, colors,
   1.124  		       ncolors * sizeof(*colors));
   1.125  	}
   1.126  	SDL_FormatChanged(screen);
   1.127 @@ -1162,7 +1162,7 @@
   1.128  		/* We need to copy the new colors, since we haven't
   1.129  		 * already done the copy in the logical set above.
   1.130  		 */
   1.131 -		memcpy(video->physpal->colors + firstcolor,
   1.132 +		SDL_memcpy(video->physpal->colors + firstcolor,
   1.133  		       colors, ncolors * sizeof(*colors));
   1.134  	}
   1.135  	if ( screen == SDL_ShadowSurface ) {
   1.136 @@ -1187,7 +1187,7 @@
   1.137  					SDL_Palette *pp = video->physpal;
   1.138  					if(!pp)
   1.139  						pp = screen->format->palette;
   1.140 -					video->gammacols = malloc(pp->ncolors
   1.141 +					video->gammacols = SDL_malloc(pp->ncolors
   1.142  							  * sizeof(SDL_Color));
   1.143  					SDL_ApplyGamma(video->gamma,
   1.144  						       pp->colors,
   1.145 @@ -1284,18 +1284,18 @@
   1.146  		if(!video->physpal && !(which & SDL_LOGPAL) ) {
   1.147  			/* Lazy physical palette allocation */
   1.148  			int size;
   1.149 -			SDL_Palette *pp = malloc(sizeof(*pp));
   1.150 +			SDL_Palette *pp = SDL_malloc(sizeof(*pp));
   1.151  			if ( !pp ) {
   1.152  				return 0;
   1.153  			}
   1.154  			current_video->physpal = pp;
   1.155  			pp->ncolors = pal->ncolors;
   1.156  			size = pp->ncolors * sizeof(SDL_Color);
   1.157 -			pp->colors = malloc(size);
   1.158 +			pp->colors = SDL_malloc(size);
   1.159  			if ( !pp->colors ) {
   1.160  				return 0;
   1.161  			}
   1.162 -			memcpy(pp->colors, pal->colors, size);
   1.163 +			SDL_memcpy(pp->colors, pal->colors, size);
   1.164  		}
   1.165  		if ( ! SetPalette_physical(screen,
   1.166  		                           colors, firstcolor, ncolors) ) {
   1.167 @@ -1351,24 +1351,24 @@
   1.168  
   1.169  		/* Clean up miscellaneous memory */
   1.170  		if ( video->physpal ) {
   1.171 -			free(video->physpal->colors);
   1.172 -			free(video->physpal);
   1.173 +			SDL_free(video->physpal->colors);
   1.174 +			SDL_free(video->physpal);
   1.175  			video->physpal = NULL;
   1.176  		}
   1.177  		if ( video->gammacols ) {
   1.178 -			free(video->gammacols);
   1.179 +			SDL_free(video->gammacols);
   1.180  			video->gammacols = NULL;
   1.181  		}
   1.182  		if ( video->gamma ) {
   1.183 -			free(video->gamma);
   1.184 +			SDL_free(video->gamma);
   1.185  			video->gamma = NULL;
   1.186  		}
   1.187  		if ( video->wm_title != NULL ) {
   1.188 -			free(video->wm_title);
   1.189 +			SDL_free(video->wm_title);
   1.190  			video->wm_title = NULL;
   1.191  		}
   1.192  		if ( video->wm_icon != NULL ) {
   1.193 -			free(video->wm_icon);
   1.194 +			SDL_free(video->wm_icon);
   1.195  			video->wm_icon = NULL;
   1.196  		}
   1.197  
   1.198 @@ -1668,20 +1668,20 @@
   1.199  	if ( video ) {
   1.200  		if ( title ) {
   1.201  			if ( video->wm_title ) {
   1.202 -				free(video->wm_title);
   1.203 +				SDL_free(video->wm_title);
   1.204  			}
   1.205 -			video->wm_title = (char *)malloc(strlen(title)+1);
   1.206 +			video->wm_title = (char *)SDL_malloc(SDL_strlen(title)+1);
   1.207  			if ( video->wm_title != NULL ) {
   1.208 -				strcpy(video->wm_title, title);
   1.209 +				SDL_strcpy(video->wm_title, title);
   1.210  			}
   1.211  		}
   1.212  		if ( icon ) {
   1.213  			if ( video->wm_icon ) {
   1.214 -				free(video->wm_icon);
   1.215 +				SDL_free(video->wm_icon);
   1.216  			}
   1.217 -			video->wm_icon = (char *)malloc(strlen(icon)+1);
   1.218 +			video->wm_icon = (char *)SDL_malloc(SDL_strlen(icon)+1);
   1.219  			if ( video->wm_icon != NULL ) {
   1.220 -				strcpy(video->wm_icon, icon);
   1.221 +				SDL_strcpy(video->wm_icon, icon);
   1.222  			}
   1.223  		}
   1.224  		if ( (title || icon) && (video->SetCaption != NULL) ) {
   1.225 @@ -1773,18 +1773,18 @@
   1.226  		if ( mask == NULL ) {
   1.227  			int mask_len = icon->h*(icon->w+7)/8;
   1.228  			int flags = 0;
   1.229 -			mask = (Uint8 *)malloc(mask_len);
   1.230 +			mask = (Uint8 *)SDL_malloc(mask_len);
   1.231  			if ( mask == NULL ) {
   1.232  				return;
   1.233  			}
   1.234 -			memset(mask, ~0, mask_len);
   1.235 +			SDL_memset(mask, ~0, mask_len);
   1.236  			if ( icon->flags & SDL_SRCCOLORKEY ) flags |= 1;
   1.237  			if ( icon->flags & SDL_SRCALPHA ) flags |= 2;
   1.238  			if( flags ) {
   1.239  				CreateMaskFromColorKeyOrAlpha(icon, mask, flags);
   1.240  			}
   1.241  			video->SetIcon(video, icon, mask);
   1.242 -			free(mask);
   1.243 +			SDL_free(mask);
   1.244  		} else {
   1.245  			video->SetIcon(this, icon, mask);
   1.246  		}