src/video/windx5/SDL_dx5video.c
changeset 1336 3692456e7b0f
parent 1330 450721ad5436
child 1338 604d73db6802
     1.1 --- a/src/video/windx5/SDL_dx5video.c	Mon Feb 06 17:28:04 2006 +0000
     1.2 +++ b/src/video/windx5/SDL_dx5video.c	Tue Feb 07 06:59:48 2006 +0000
     1.3 @@ -472,7 +472,7 @@
     1.4  	      LPDIRECTDRAWSURFACE3 DDrawSurf3;
     1.5  
     1.6  	      /* Try to create a DirectDrawSurface3 object */
     1.7 -	      memset(&desc, 0, sizeof(desc));
     1.8 +	      SDL_memset(&desc, 0, sizeof(desc));
     1.9  	      desc.dwSize = sizeof(desc);
    1.10  	      desc.dwFlags = DDSD_CAPS;
    1.11  	      desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE|DDSCAPS_VIDEOMEMORY;
    1.12 @@ -546,12 +546,12 @@
    1.13  	DX5_Unload();
    1.14  	if ( this ) {
    1.15  		if ( this->hidden ) {
    1.16 -			free(this->hidden);
    1.17 +			SDL_free(this->hidden);
    1.18  		}
    1.19  		if ( this->gl_data ) {
    1.20 -			free(this->gl_data);
    1.21 +			SDL_free(this->gl_data);
    1.22  		}
    1.23 -		free(this);
    1.24 +		SDL_free(this);
    1.25  	}
    1.26  }
    1.27  
    1.28 @@ -565,13 +565,13 @@
    1.29  	}
    1.30  
    1.31  	/* Initialize all variables that we clean on shutdown */
    1.32 -	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
    1.33 +	device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
    1.34  	if ( device ) {
    1.35 -		memset(device, 0, (sizeof *device));
    1.36 +		SDL_memset(device, 0, (sizeof *device));
    1.37  		device->hidden = (struct SDL_PrivateVideoData *)
    1.38 -				malloc((sizeof *device->hidden));
    1.39 +				SDL_malloc((sizeof *device->hidden));
    1.40  		device->gl_data = (struct SDL_PrivateGLData *)
    1.41 -				malloc((sizeof *device->gl_data));
    1.42 +				SDL_malloc((sizeof *device->gl_data));
    1.43  	}
    1.44  	if ( (device == NULL) || (device->hidden == NULL) ||
    1.45  		                 (device->gl_data == NULL) ) {
    1.46 @@ -579,8 +579,8 @@
    1.47  		DX5_DeleteDevice(device);
    1.48  		return(NULL);
    1.49  	}
    1.50 -	memset(device->hidden, 0, (sizeof *device->hidden));
    1.51 -	memset(device->gl_data, 0, (sizeof *device->gl_data));
    1.52 +	SDL_memset(device->hidden, 0, (sizeof *device->hidden));
    1.53 +	SDL_memset(device->gl_data, 0, (sizeof *device->gl_data));
    1.54  
    1.55  	/* Set the function pointers */
    1.56  	device->VideoInit = DX5_VideoInit;
    1.57 @@ -678,7 +678,7 @@
    1.58  				break;
    1.59  			}
    1.60  			++SDL_nummodes[bpp];
    1.61 -			enumrect = (struct DX5EnumRect*)malloc(sizeof(struct DX5EnumRect));
    1.62 +			enumrect = (struct DX5EnumRect*)SDL_malloc(sizeof(struct DX5EnumRect));
    1.63  			if ( !enumrect ) {
    1.64  				SDL_OutOfMemory();
    1.65  				return(DDENUMRET_CANCEL);
    1.66 @@ -809,13 +809,13 @@
    1.67  			error = "Interface not present";
    1.68  			break;
    1.69  		default:
    1.70 -			snprintf(errbuf, SDL_arraysize(errbuf),
    1.71 +			SDL_snprintf(errbuf, SDL_arraysize(errbuf),
    1.72  			         "%s: Unknown DirectDraw error: 0x%x",
    1.73  								function, code);
    1.74  			break;
    1.75  	}
    1.76  	if ( ! errbuf[0] ) {
    1.77 -		snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error);
    1.78 +		SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error);
    1.79  	}
    1.80  	SDL_SetError("%s", errbuf);
    1.81  	return;
    1.82 @@ -837,7 +837,7 @@
    1.83  	HRESULT result;
    1.84  
    1.85  	/* Fill in our hardware acceleration capabilities */
    1.86 -	memset(&DDCaps, 0, sizeof(DDCaps));
    1.87 +	SDL_memset(&DDCaps, 0, sizeof(DDCaps));
    1.88  	DDCaps.dwSize = sizeof(DDCaps);
    1.89  	result = IDirectDraw2_GetCaps(ddraw2, (DDCAPS *)&DDCaps, NULL);
    1.90  	if ( result != DD_OK ) {
    1.91 @@ -946,7 +946,7 @@
    1.92  	for ( i=0; i<NUM_MODELISTS; ++i ) {
    1.93  		struct DX5EnumRect *rect;
    1.94  		SDL_modelist[i] = (SDL_Rect **)
    1.95 -				malloc((SDL_nummodes[i]+1)*sizeof(SDL_Rect *));
    1.96 +				SDL_malloc((SDL_nummodes[i]+1)*sizeof(SDL_Rect *));
    1.97  		if ( SDL_modelist[i] == NULL ) {
    1.98  			SDL_OutOfMemory();
    1.99  			return(-1);
   1.100 @@ -1103,7 +1103,7 @@
   1.101  			DEVMODE settings;
   1.102  			BOOL changed;
   1.103  
   1.104 -			memset(&settings, 0, sizeof(DEVMODE));
   1.105 +			SDL_memset(&settings, 0, sizeof(DEVMODE));
   1.106  			settings.dmSize = sizeof(DEVMODE);
   1.107  			settings.dmBitsPerPel = video->format->BitsPerPixel;
   1.108  			settings.dmPelsWidth = width;
   1.109 @@ -1163,14 +1163,14 @@
   1.110  			const char *center = NULL;
   1.111  
   1.112  			if ( !SDL_windowX && !SDL_windowY ) {
   1.113 -				window = getenv("SDL_VIDEO_WINDOW_POS");
   1.114 -				center = getenv("SDL_VIDEO_CENTERED");
   1.115 +				window = SDL_getenv("SDL_VIDEO_WINDOW_POS");
   1.116 +				center = SDL_getenv("SDL_VIDEO_CENTERED");
   1.117  				if ( window ) {
   1.118 -					if ( sscanf(window, "%d,%d", &x, &y) == 2 ) {
   1.119 +					if ( SDL_sscanf(window, "%d,%d", &x, &y) == 2 ) {
   1.120  						SDL_windowX = x;
   1.121  						SDL_windowY = y;
   1.122  					}
   1.123 -					if ( strcmp(window, "center") == 0 ) {
   1.124 +					if ( SDL_strcmp(window, "center") == 0 ) {
   1.125  						center = window;
   1.126  					}
   1.127  				}
   1.128 @@ -1306,7 +1306,7 @@
   1.129  	DX5_UpdateVideoInfo(this);
   1.130  
   1.131  	/* Create a primary DirectDraw surface */
   1.132 -	memset(&ddsd, 0, sizeof(ddsd));
   1.133 +	SDL_memset(&ddsd, 0, sizeof(ddsd));
   1.134  	ddsd.dwSize = sizeof(ddsd);
   1.135  	ddsd.dwFlags = DDSD_CAPS;
   1.136  	ddsd.ddsCaps.dwCaps = (DDSCAPS_PRIMARYSURFACE|DDSCAPS_VIDEOMEMORY);
   1.137 @@ -1340,7 +1340,7 @@
   1.138  	IDirectDrawSurface_Release(dd_surface1);
   1.139  
   1.140  	/* Get the format of the primary DirectDraw surface */
   1.141 -	memset(&ddsd, 0, sizeof(ddsd));
   1.142 +	SDL_memset(&ddsd, 0, sizeof(ddsd));
   1.143  	ddsd.dwSize = sizeof(ddsd);
   1.144  	ddsd.dwFlags = DDSD_PIXELFORMAT|DDSD_CAPS;
   1.145  	result = IDirectDrawSurface3_GetSurfaceDesc(SDL_primary, &ddsd);
   1.146 @@ -1465,7 +1465,7 @@
   1.147  			video->pitch = (width*video->format->BytesPerPixel);
   1.148  			/* Pitch needs to be QWORD (8-byte) aligned */
   1.149  			video->pitch = (video->pitch + 7) & ~7;
   1.150 -			video->pixels = (void *)malloc(video->h*video->pitch);
   1.151 +			video->pixels = (void *)SDL_malloc(video->h*video->pitch);
   1.152  			if ( video->pixels == NULL ) {
   1.153  				if ( video != current ) {
   1.154  					SDL_FreeSurface(video);
   1.155 @@ -1493,7 +1493,7 @@
   1.156  	} else {
   1.157  		/* Necessary if we're going from window to fullscreen */
   1.158  		if ( video->pixels != NULL ) {
   1.159 -			free(video->pixels);
   1.160 +			SDL_free(video->pixels);
   1.161  			video->pixels = NULL;
   1.162  		}
   1.163  		dd_surface3 = SDL_primary;
   1.164 @@ -1566,14 +1566,14 @@
   1.165  			const char *center = NULL;
   1.166  
   1.167  			if ( !SDL_windowX && !SDL_windowY ) {
   1.168 -				window = getenv("SDL_VIDEO_WINDOW_POS");
   1.169 -				center = getenv("SDL_VIDEO_CENTERED");
   1.170 +				window = SDL_getenv("SDL_VIDEO_WINDOW_POS");
   1.171 +				center = SDL_getenv("SDL_VIDEO_CENTERED");
   1.172  				if ( window ) {
   1.173 -					if ( sscanf(window, "%d,%d", &x, &y) == 2 ) {
   1.174 +					if ( SDL_sscanf(window, "%d,%d", &x, &y) == 2 ) {
   1.175  						SDL_windowX = x;
   1.176  						SDL_windowY = y;
   1.177  					}
   1.178 -					if ( strcmp(window, "center") == 0 ) {
   1.179 +					if ( SDL_strcmp(window, "center") == 0 ) {
   1.180  						center = window;
   1.181  					}
   1.182  				}
   1.183 @@ -1629,7 +1629,7 @@
   1.184  
   1.185  	/* Allocate the hardware acceleration data */
   1.186  	surface->hwdata = (struct private_hwdata *)
   1.187 -					malloc(sizeof(*surface->hwdata));
   1.188 +					SDL_malloc(sizeof(*surface->hwdata));
   1.189  	if ( surface->hwdata == NULL ) {
   1.190  		SDL_OutOfMemory();
   1.191  		return(-1);
   1.192 @@ -1637,7 +1637,7 @@
   1.193  	dd_surface3 = NULL;
   1.194  
   1.195  	/* Set up the surface description */
   1.196 -	memset(&ddsd, 0, sizeof(ddsd));
   1.197 +	SDL_memset(&ddsd, 0, sizeof(ddsd));
   1.198  	ddsd.dwSize = sizeof(ddsd);
   1.199  	ddsd.dwFlags = (DDSD_WIDTH|DDSD_HEIGHT|DDSD_CAPS|
   1.200  					DDSD_PITCH|DDSD_PIXELFORMAT);
   1.201 @@ -1720,7 +1720,7 @@
   1.202  	}
   1.203  
   1.204  	/* Make sure the surface format was set properly */
   1.205 -	memset(&ddsd, 0, sizeof(ddsd));
   1.206 +	SDL_memset(&ddsd, 0, sizeof(ddsd));
   1.207  	ddsd.dwSize = sizeof(ddsd);
   1.208  	result = IDirectDrawSurface3_Lock(dd_surface3, NULL,
   1.209  		&ddsd, (DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL);
   1.210 @@ -1804,7 +1804,7 @@
   1.211  	if ( (dd_surface3 != NULL) && (dd_surface3 != requested) ) {
   1.212  		IDirectDrawSurface_Release(dd_surface3);
   1.213  	}
   1.214 -	free(surface->hwdata);
   1.215 +	SDL_free(surface->hwdata);
   1.216  	surface->hwdata = NULL;
   1.217  	return(-1);
   1.218  }
   1.219 @@ -1825,7 +1825,7 @@
   1.220  	DDSURFACEDESC ddsd;
   1.221  
   1.222  	/* Lock and load! */
   1.223 -	memset(&ddsd, 0, sizeof(ddsd));
   1.224 +	SDL_memset(&ddsd, 0, sizeof(ddsd));
   1.225  	ddsd.dwSize = sizeof(ddsd);
   1.226  	if ( IDirectDrawSurface3_Lock(surface, NULL, &ddsd,
   1.227  			(DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL) != DD_OK ) {
   1.228 @@ -2013,7 +2013,7 @@
   1.229  
   1.230  	/* Lock and load! */
   1.231  	dd_surface = surface->hwdata->dd_writebuf;
   1.232 -	memset(&ddsd, 0, sizeof(ddsd));
   1.233 +	SDL_memset(&ddsd, 0, sizeof(ddsd));
   1.234  	ddsd.dwSize = sizeof(ddsd);
   1.235  	result = IDirectDrawSurface3_Lock(dd_surface, NULL, &ddsd,
   1.236  					(DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL);
   1.237 @@ -2081,7 +2081,7 @@
   1.238  		if ( surface->hwdata->dd_surface != SDL_primary ) {
   1.239  			IDirectDrawSurface3_Release(surface->hwdata->dd_surface);
   1.240  		}
   1.241 -		free(surface->hwdata);
   1.242 +		SDL_free(surface->hwdata);
   1.243  		surface->hwdata = NULL;
   1.244  	}
   1.245  }
   1.246 @@ -2177,7 +2177,7 @@
   1.247  		return;
   1.248  	}
   1.249  	seen = pool;
   1.250 -	memset(seen, 0, ncolors*sizeof(int));
   1.251 +	SDL_memset(seen, 0, ncolors*sizeof(int));
   1.252  	order = pool+ncolors;
   1.253  
   1.254  	/* Start with the brightest color */
   1.255 @@ -2287,9 +2287,9 @@
   1.256  	}
   1.257  
   1.258  	/* Set up the gamma ramp */
   1.259 -	memcpy(gamma_ramp.red, &ramp[0*256], 256*sizeof(*ramp));
   1.260 -	memcpy(gamma_ramp.green, &ramp[1*256], 256*sizeof(*ramp));
   1.261 -	memcpy(gamma_ramp.blue, &ramp[2*256], 256*sizeof(*ramp));
   1.262 +	SDL_memcpy(gamma_ramp.red, &ramp[0*256], 256*sizeof(*ramp));
   1.263 +	SDL_memcpy(gamma_ramp.green, &ramp[1*256], 256*sizeof(*ramp));
   1.264 +	SDL_memcpy(gamma_ramp.blue, &ramp[2*256], 256*sizeof(*ramp));
   1.265  	result = IDirectDrawGammaControl_SetGammaRamp(gamma, 0, &gamma_ramp);
   1.266  	if ( result != DD_OK ) {
   1.267  		SetDDerror("DirectDrawGammaControl::SetGammaRamp()", result);
   1.268 @@ -2335,9 +2335,9 @@
   1.269  	/* Set up the gamma ramp */
   1.270  	result = IDirectDrawGammaControl_GetGammaRamp(gamma, 0, &gamma_ramp);
   1.271  	if ( result == DD_OK ) {
   1.272 -		memcpy(&ramp[0*256], gamma_ramp.red, 256*sizeof(*ramp));
   1.273 -		memcpy(&ramp[1*256], gamma_ramp.green, 256*sizeof(*ramp));
   1.274 -		memcpy(&ramp[2*256], gamma_ramp.blue, 256*sizeof(*ramp));
   1.275 +		SDL_memcpy(&ramp[0*256], gamma_ramp.red, 256*sizeof(*ramp));
   1.276 +		SDL_memcpy(&ramp[1*256], gamma_ramp.green, 256*sizeof(*ramp));
   1.277 +		SDL_memcpy(&ramp[2*256], gamma_ramp.blue, 256*sizeof(*ramp));
   1.278  	} else {
   1.279  		SetDDerror("DirectDrawGammaControl::GetGammaRamp()", result);
   1.280  	}
   1.281 @@ -2391,8 +2391,8 @@
   1.282  	for ( i=0; i<NUM_MODELISTS; ++i ) {
   1.283  		if ( SDL_modelist[i] != NULL ) {
   1.284  			for ( j=0; SDL_modelist[i][j]; ++j )
   1.285 -				free(SDL_modelist[i][j]);
   1.286 -			free(SDL_modelist[i]);
   1.287 +				SDL_free(SDL_modelist[i][j]);
   1.288 +			SDL_free(SDL_modelist[i]);
   1.289  			SDL_modelist[i] = NULL;
   1.290  		}
   1.291  	}
   1.292 @@ -2466,7 +2466,7 @@
   1.293  	ReleaseDC(window, hdc);
   1.294  	if ( ! colorchange_expected ) {
   1.295  		saved = SDL_stack_alloc(SDL_Color, palette->ncolors);
   1.296 -		memcpy(saved, palette->colors, 
   1.297 +		SDL_memcpy(saved, palette->colors, 
   1.298  					palette->ncolors*sizeof(SDL_Color));
   1.299  	}
   1.300  	for ( i=0; i<palette->ncolors; ++i ) {
   1.301 @@ -2478,7 +2478,7 @@
   1.302  	if ( ! colorchange_expected ) {
   1.303  		Uint8 mapping[256];
   1.304  
   1.305 -		memset(mapping, 0, sizeof(mapping));
   1.306 +		SDL_memset(mapping, 0, sizeof(mapping));
   1.307  		for ( i=0; i<palette->ncolors; ++i ) {
   1.308  			mapping[i] = SDL_FindColor(palette,
   1.309  					saved[i].r, saved[i].g, saved[i].b);