comparison src/video/svga/SDL_svgavideo.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 c9b51268668f
children 604d73db6802
comparison
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
102 return(((svgalib2 != -1) || (geteuid() == 0)) && (console >= 0)); 102 return(((svgalib2 != -1) || (geteuid() == 0)) && (console >= 0));
103 } 103 }
104 104
105 static void SVGA_DeleteDevice(SDL_VideoDevice *device) 105 static void SVGA_DeleteDevice(SDL_VideoDevice *device)
106 { 106 {
107 free(device->hidden); 107 SDL_free(device->hidden);
108 free(device); 108 SDL_free(device);
109 } 109 }
110 110
111 static SDL_VideoDevice *SVGA_CreateDevice(int devindex) 111 static SDL_VideoDevice *SVGA_CreateDevice(int devindex)
112 { 112 {
113 SDL_VideoDevice *device; 113 SDL_VideoDevice *device;
114 114
115 /* Initialize all variables that we clean on shutdown */ 115 /* Initialize all variables that we clean on shutdown */
116 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); 116 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
117 if ( device ) { 117 if ( device ) {
118 memset(device, 0, (sizeof *device)); 118 SDL_memset(device, 0, (sizeof *device));
119 device->hidden = (struct SDL_PrivateVideoData *) 119 device->hidden = (struct SDL_PrivateVideoData *)
120 malloc((sizeof *device->hidden)); 120 SDL_malloc((sizeof *device->hidden));
121 } 121 }
122 if ( (device == NULL) || (device->hidden == NULL) ) { 122 if ( (device == NULL) || (device->hidden == NULL) ) {
123 SDL_OutOfMemory(); 123 SDL_OutOfMemory();
124 if ( device ) { 124 if ( device ) {
125 free(device); 125 SDL_free(device);
126 } 126 }
127 return(0); 127 return(0);
128 } 128 }
129 memset(device->hidden, 0, (sizeof *device->hidden)); 129 SDL_memset(device->hidden, 0, (sizeof *device->hidden));
130 130
131 /* Set the function pointers */ 131 /* Set the function pointers */
132 device->VideoInit = SVGA_VideoInit; 132 device->VideoInit = SVGA_VideoInit;
133 device->ListModes = SVGA_ListModes; 133 device->ListModes = SVGA_ListModes;
134 device->SetVideoMode = SVGA_SetVideoMode; 134 device->SetVideoMode = SVGA_SetVideoMode;
276 if ( total_modes == 0 ) { 276 if ( total_modes == 0 ) {
277 SDL_SetError("No linear video modes available"); 277 SDL_SetError("No linear video modes available");
278 return(-1); 278 return(-1);
279 } 279 }
280 for ( i=0; i<NUM_MODELISTS; ++i ) { 280 for ( i=0; i<NUM_MODELISTS; ++i ) {
281 SDL_vgamode[i] = (int *)malloc(SDL_nummodes[i]*sizeof(int)); 281 SDL_vgamode[i] = (int *)SDL_malloc(SDL_nummodes[i]*sizeof(int));
282 if ( SDL_vgamode[i] == NULL ) { 282 if ( SDL_vgamode[i] == NULL ) {
283 SDL_OutOfMemory(); 283 SDL_OutOfMemory();
284 return(-1); 284 return(-1);
285 } 285 }
286 SDL_modelist[i] = (SDL_Rect **) 286 SDL_modelist[i] = (SDL_Rect **)
287 malloc((SDL_nummodes[i]+1)*sizeof(SDL_Rect *)); 287 SDL_malloc((SDL_nummodes[i]+1)*sizeof(SDL_Rect *));
288 if ( SDL_modelist[i] == NULL ) { 288 if ( SDL_modelist[i] == NULL ) {
289 SDL_OutOfMemory(); 289 SDL_OutOfMemory();
290 return(-1); 290 return(-1);
291 } 291 }
292 for ( j=0; j<SDL_nummodes[i]; ++j ) { 292 for ( j=0; j<SDL_nummodes[i]; ++j ) {
293 SDL_modelist[i][j]=(SDL_Rect *)malloc(sizeof(SDL_Rect)); 293 SDL_modelist[i][j]=(SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));
294 if ( SDL_modelist[i][j] == NULL ) { 294 if ( SDL_modelist[i][j] == NULL ) {
295 SDL_OutOfMemory(); 295 SDL_OutOfMemory();
296 return(-1); 296 return(-1);
297 } 297 }
298 memset(SDL_modelist[i][j], 0, sizeof(SDL_Rect)); 298 SDL_memset(SDL_modelist[i][j], 0, sizeof(SDL_Rect));
299 } 299 }
300 SDL_modelist[i][j] = NULL; 300 SDL_modelist[i][j] = NULL;
301 } 301 }
302 for ( mode=vga_lastmodenumber(); mode; --mode ) { 302 for ( mode=vga_lastmodenumber(); mode; --mode ) {
303 if ( vga_hasmode(mode) ) { 303 if ( vga_hasmode(mode) ) {
311 j = 0; 311 j = 0;
312 while ( SDL_modelist[i][j] && SDL_modelist[i][j]->w ) { 312 while ( SDL_modelist[i][j] && SDL_modelist[i][j]->w ) {
313 j++; 313 j++;
314 } 314 }
315 while ( SDL_modelist[i][j] ) { 315 while ( SDL_modelist[i][j] ) {
316 free(SDL_modelist[i][j]); 316 SDL_free(SDL_modelist[i][j]);
317 SDL_modelist[i][j] = NULL; 317 SDL_modelist[i][j] = NULL;
318 j++; 318 j++;
319 } 319 }
320 } 320 }
321 321
495 495
496 /* Free video mode lists */ 496 /* Free video mode lists */
497 for ( i=0; i<NUM_MODELISTS; ++i ) { 497 for ( i=0; i<NUM_MODELISTS; ++i ) {
498 if ( SDL_modelist[i] != NULL ) { 498 if ( SDL_modelist[i] != NULL ) {
499 for ( j=0; SDL_modelist[i][j]; ++j ) 499 for ( j=0; SDL_modelist[i][j]; ++j )
500 free(SDL_modelist[i][j]); 500 SDL_free(SDL_modelist[i][j]);
501 free(SDL_modelist[i]); 501 SDL_free(SDL_modelist[i]);
502 SDL_modelist[i] = NULL; 502 SDL_modelist[i] = NULL;
503 } 503 }
504 if ( SDL_vgamode[i] != NULL ) { 504 if ( SDL_vgamode[i] != NULL ) {
505 free(SDL_vgamode[i]); 505 SDL_free(SDL_vgamode[i]);
506 SDL_vgamode[i] = NULL; 506 SDL_vgamode[i] = NULL;
507 } 507 }
508 } 508 }
509 if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) { 509 if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) {
510 /* Direct screen access, no memory buffer */ 510 /* Direct screen access, no memory buffer */