comparison src/video/vgl/SDL_vglvideo.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
106 return hires_available; 106 return hires_available;
107 } 107 }
108 108
109 static void VGL_DeleteDevice(SDL_VideoDevice *device) 109 static void VGL_DeleteDevice(SDL_VideoDevice *device)
110 { 110 {
111 free(device->hidden); 111 SDL_free(device->hidden);
112 free(device); 112 SDL_free(device);
113 } 113 }
114 114
115 static SDL_VideoDevice *VGL_CreateDevice(int devindex) 115 static SDL_VideoDevice *VGL_CreateDevice(int devindex)
116 { 116 {
117 SDL_VideoDevice *device; 117 SDL_VideoDevice *device;
118 118
119 /* Initialize all variables that we clean on shutdown */ 119 /* Initialize all variables that we clean on shutdown */
120 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); 120 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
121 if ( device ) { 121 if ( device ) {
122 memset(device, 0, (sizeof *device)); 122 SDL_memset(device, 0, (sizeof *device));
123 device->hidden = (struct SDL_PrivateVideoData *) 123 device->hidden = (struct SDL_PrivateVideoData *)
124 malloc((sizeof *device->hidden)); 124 SDL_malloc((sizeof *device->hidden));
125 } 125 }
126 if ( (device == NULL) || (device->hidden == NULL) ) { 126 if ( (device == NULL) || (device->hidden == NULL) ) {
127 SDL_OutOfMemory(); 127 SDL_OutOfMemory();
128 if ( device ) { 128 if ( device ) {
129 free(device); 129 SDL_free(device);
130 } 130 }
131 return(0); 131 return(0);
132 } 132 }
133 memset(device->hidden, 0, (sizeof *device->hidden)); 133 SDL_memset(device->hidden, 0, (sizeof *device->hidden));
134 134
135 /* Set the function pointers */ 135 /* Set the function pointers */
136 device->VideoInit = VGL_VideoInit; 136 device->VideoInit = VGL_VideoInit;
137 device->ListModes = VGL_ListModes; 137 device->ListModes = VGL_ListModes;
138 device->SetVideoMode = VGL_SetVideoMode; 138 device->SetVideoMode = VGL_SetVideoMode;
186 (mode->h == inmode->ModeInfo.Ysize)) 186 (mode->h == inmode->ModeInfo.Ysize))
187 return 0; 187 return 0;
188 } 188 }
189 189
190 /* Set up the new video mode rectangle */ 190 /* Set up the new video mode rectangle */
191 mode = (SDL_Rect *)malloc(sizeof *mode); 191 mode = (SDL_Rect *)SDL_malloc(sizeof *mode);
192 if (mode == NULL) { 192 if (mode == NULL) {
193 SDL_OutOfMemory(); 193 SDL_OutOfMemory();
194 return -1; 194 return -1;
195 } 195 }
196 mode->x = 0; 196 mode->x = 0;
199 mode->h = inmode->ModeInfo.Ysize; 199 mode->h = inmode->ModeInfo.Ysize;
200 200
201 /* Allocate the new list of modes, and fill in the new mode */ 201 /* Allocate the new list of modes, and fill in the new mode */
202 next_mode = SDL_nummodes[index]; 202 next_mode = SDL_nummodes[index];
203 SDL_modelist[index] = (SDL_Rect **) 203 SDL_modelist[index] = (SDL_Rect **)
204 realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); 204 SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
205 if (SDL_modelist[index] == NULL) { 205 if (SDL_modelist[index] == NULL) {
206 SDL_OutOfMemory(); 206 SDL_OutOfMemory();
207 SDL_nummodes[index] = 0; 207 SDL_nummodes[index] = 0;
208 free(mode); 208 SDL_free(mode);
209 return -1; 209 return -1;
210 } 210 }
211 SDL_modelist[index][next_mode] = mode; 211 SDL_modelist[index][next_mode] = mode;
212 SDL_modelist[index][next_mode+1] = NULL; 212 SDL_modelist[index][next_mode+1] = NULL;
213 SDL_nummodes[index]++; 213 SDL_nummodes[index]++;
241 SDL_nummodes[i] = 0; 241 SDL_nummodes[i] = 0;
242 SDL_modelist[i] = NULL; 242 SDL_modelist[i] = NULL;
243 } 243 }
244 244
245 /* Enable mouse and keyboard support */ 245 /* Enable mouse and keyboard support */
246 if (getenv("SDL_NO_RAWKBD") == NULL) { 246 if (SDL_getenv("SDL_NO_RAWKBD") == NULL) {
247 if (VGLKeyboardInit(VGL_CODEKEYS) != 0) { 247 if (VGLKeyboardInit(VGL_CODEKEYS) != 0) {
248 SDL_SetError("Unable to initialize keyboard"); 248 SDL_SetError("Unable to initialize keyboard");
249 return -1; 249 return -1;
250 } 250 }
251 } else { 251 } else {
338 if (VGLInit(modes[i]->ModeId) != 0) { 338 if (VGLInit(modes[i]->ModeId) != 0) {
339 SDL_SetError("Unable to switch to requested mode"); 339 SDL_SetError("Unable to switch to requested mode");
340 return NULL; 340 return NULL;
341 } 341 }
342 342
343 VGLCurMode = realloc(VGLCurMode, sizeof(VGLMode)); 343 VGLCurMode = SDL_realloc(VGLCurMode, sizeof(VGLMode));
344 VGLCurMode->ModeInfo = *VGLDisplay; 344 VGLCurMode->ModeInfo = *VGLDisplay;
345 VGLCurMode->Depth = modes[i]->Depth; 345 VGLCurMode->Depth = modes[i]->Depth;
346 VGLCurMode->ModeId = modes[i]->ModeId; 346 VGLCurMode->ModeId = modes[i]->ModeId;
347 VGLCurMode->Rmask = modes[i]->Rmask; 347 VGLCurMode->Rmask = modes[i]->Rmask;
348 VGLCurMode->Gmask = modes[i]->Gmask; 348 VGLCurMode->Gmask = modes[i]->Gmask;
464 VGLKeyboardEnd(); 464 VGLKeyboardEnd();
465 465
466 /* Reset the console video mode if we actually initialised one */ 466 /* Reset the console video mode if we actually initialised one */
467 if (VGLCurMode != NULL) { 467 if (VGLCurMode != NULL) {
468 VGLEnd(); 468 VGLEnd();
469 free(VGLCurMode); 469 SDL_free(VGLCurMode);
470 VGLCurMode = NULL; 470 VGLCurMode = NULL;
471 } 471 }
472 472
473 /* Clear the lock mutex */ 473 /* Clear the lock mutex */
474 if (hw_lock != NULL) { 474 if (hw_lock != NULL) {
478 478
479 /* Free video mode lists */ 479 /* Free video mode lists */
480 for (i = 0; i < NUM_MODELISTS; i++) { 480 for (i = 0; i < NUM_MODELISTS; i++) {
481 if (SDL_modelist[i] != NULL) { 481 if (SDL_modelist[i] != NULL) {
482 for (j = 0; SDL_modelist[i][j] != NULL; ++j) { 482 for (j = 0; SDL_modelist[i][j] != NULL; ++j) {
483 free(SDL_modelist[i][j]); 483 SDL_free(SDL_modelist[i][j]);
484 } 484 }
485 free(SDL_modelist[i]); 485 SDL_free(SDL_modelist[i]);
486 SDL_modelist[i] = NULL; 486 SDL_modelist[i] = NULL;
487 } 487 }
488 } 488 }
489 489
490 if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) { 490 if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) {
506 VGLMode **modesp, *modescp; 506 VGLMode **modesp, *modescp;
507 video_info_t minfo; 507 video_info_t minfo;
508 int adptype, i, modenum; 508 int adptype, i, modenum;
509 509
510 if (modes == NULL) { 510 if (modes == NULL) {
511 modes = malloc(sizeof(VGLMode *) * M_VESA_MODE_MAX); 511 modes = SDL_malloc(sizeof(VGLMode *) * M_VESA_MODE_MAX);
512 bzero(modes, sizeof(VGLMode *) * M_VESA_MODE_MAX); 512 bzero(modes, sizeof(VGLMode *) * M_VESA_MODE_MAX);
513 } 513 }
514 modesp = modes; 514 modesp = modes;
515 515
516 for (modenum = 0; modenum < M_VESA_MODE_MAX; modenum++) { 516 for (modenum = 0; modenum < M_VESA_MODE_MAX; modenum++) {
619 619
620 modesp++; 620 modesp++;
621 } 621 }
622 622
623 if (*modesp != NULL) { 623 if (*modesp != NULL) {
624 free(*modesp); 624 SDL_free(*modesp);
625 *modesp = NULL; 625 *modesp = NULL;
626 } 626 }
627 627
628 return modes; 628 return modes;
629 } 629 }