comparison src/video/epoc/SDL_epocvideo.cpp @ 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 f6ffac90895c
children 604d73db6802
comparison
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
129 return 1; /* Always available */ 129 return 1; /* Always available */
130 } 130 }
131 131
132 static void EPOC_DeleteDevice(SDL_VideoDevice *device) 132 static void EPOC_DeleteDevice(SDL_VideoDevice *device)
133 { 133 {
134 free(device->hidden); 134 SDL_free(device->hidden);
135 free(device); 135 SDL_free(device);
136 } 136 }
137 137
138 static SDL_VideoDevice *EPOC_CreateDevice(int devindex) 138 static SDL_VideoDevice *EPOC_CreateDevice(int devindex)
139 { 139 {
140 SDL_VideoDevice *device; 140 SDL_VideoDevice *device;
141 141
142 /* Allocate all variables that we free on delete */ 142 /* Allocate all variables that we free on delete */
143 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); 143 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
144 if ( device ) { 144 if ( device ) {
145 memset(device, 0, (sizeof *device)); 145 SDL_memset(device, 0, (sizeof *device));
146 device->hidden = (struct SDL_PrivateVideoData *) 146 device->hidden = (struct SDL_PrivateVideoData *)
147 malloc((sizeof *device->hidden)); 147 SDL_malloc((sizeof *device->hidden));
148 } 148 }
149 if ( (device == NULL) || (device->hidden == NULL) ) { 149 if ( (device == NULL) || (device->hidden == NULL) ) {
150 SDL_OutOfMemory(); 150 SDL_OutOfMemory();
151 if ( device ) { 151 if ( device ) {
152 free(device); 152 SDL_free(device);
153 } 153 }
154 return(0); 154 return(0);
155 } 155 }
156 memset(device->hidden, 0, (sizeof *device->hidden)); 156 SDL_memset(device->hidden, 0, (sizeof *device->hidden));
157 157
158 /* Set the function pointers */ 158 /* Set the function pointers */
159 device->VideoInit = EPOC_VideoInit; 159 device->VideoInit = EPOC_VideoInit;
160 device->ListModes = EPOC_ListModes; 160 device->ListModes = EPOC_ListModes;
161 device->SetVideoMode = EPOC_SetVideoMode; 161 device->SetVideoMode = EPOC_SetVideoMode;
238 int i; 238 int i;
239 239
240 /* Initialize all variables that we clean on shutdown */ 240 /* Initialize all variables that we clean on shutdown */
241 241
242 for ( i=0; i<SDL_NUMMODES; ++i ) { 242 for ( i=0; i<SDL_NUMMODES; ++i ) {
243 Private->SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); 243 Private->SDL_modelist[i] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));
244 Private->SDL_modelist[i]->x = Private->SDL_modelist[i]->y = 0; 244 Private->SDL_modelist[i]->x = Private->SDL_modelist[i]->y = 0;
245 } 245 }
246 /* Modes sorted largest to smallest !!TODO:sorting order??*/ 246 /* Modes sorted largest to smallest !!TODO:sorting order??*/
247 Private->SDL_modelist[0]->w = 640; Private->SDL_modelist[0]->h = 200; 247 Private->SDL_modelist[0]->w = 640; Private->SDL_modelist[0]->h = 200;
248 Private->SDL_modelist[1]->w = 320; Private->SDL_modelist[1]->h = 200; 248 Private->SDL_modelist[1]->w = 320; Private->SDL_modelist[1]->h = 200;
355 SDL_SetError("Requested video mode is not supported"); 355 SDL_SetError("Requested video mode is not supported");
356 return NULL; 356 return NULL;
357 } 357 }
358 358
359 if (current && current->pixels) { 359 if (current && current->pixels) {
360 free(current->pixels); 360 SDL_free(current->pixels);
361 current->pixels = NULL; 361 current->pixels = NULL;
362 } 362 }
363 if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) { 363 if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) {
364 return(NULL); 364 return(NULL);
365 } 365 }
371 current->flags = (SDL_FULLSCREEN|SDL_SWSURFACE|SDL_PREALLOC); 371 current->flags = (SDL_FULLSCREEN|SDL_SWSURFACE|SDL_PREALLOC);
372 current->w = width; 372 current->w = width;
373 current->h = height; 373 current->h = height;
374 int numBytesPerPixel = ((bpp-1)>>3) + 1; 374 int numBytesPerPixel = ((bpp-1)>>3) + 1;
375 current->pitch = numBytesPerPixel * width; // Number of bytes in scanline 375 current->pitch = numBytesPerPixel * width; // Number of bytes in scanline
376 current->pixels = malloc(width * height * numBytesPerPixel); 376 current->pixels = SDL_malloc(width * height * numBytesPerPixel);
377 memset(current->pixels, 0, width * height * numBytesPerPixel); 377 SDL_memset(current->pixels, 0, width * height * numBytesPerPixel);
378 378
379 /* Set the blit function */ 379 /* Set the blit function */
380 _this->UpdateRects = EPOC_DirectUpdate; 380 _this->UpdateRects = EPOC_DirectUpdate;
381 381
382 /* Must buffer height be shrinked to screen by 2 ? */ 382 /* Must buffer height be shrinked to screen by 2 ? */
620 int i; 620 int i;
621 621
622 /* Free video mode lists */ 622 /* Free video mode lists */
623 for ( i=0; i<SDL_NUMMODES; ++i ) { 623 for ( i=0; i<SDL_NUMMODES; ++i ) {
624 if ( Private->SDL_modelist[i] != NULL ) { 624 if ( Private->SDL_modelist[i] != NULL ) {
625 free(Private->SDL_modelist[i]); 625 SDL_free(Private->SDL_modelist[i]);
626 Private->SDL_modelist[i] = NULL; 626 Private->SDL_modelist[i] = NULL;
627 } 627 }
628 } 628 }
629 629
630 if ( _this->screen && (_this->screen->flags & SDL_HWSURFACE) ) { 630 if ( _this->screen && (_this->screen->flags & SDL_HWSURFACE) ) {
631 /* Direct screen access, no memory buffer */ 631 /* Direct screen access, no memory buffer */
632 _this->screen->pixels = NULL; 632 _this->screen->pixels = NULL;
633 } 633 }
634 634
635 if (_this->screen && _this->screen->pixels) { 635 if (_this->screen && _this->screen->pixels) {
636 free(_this->screen->pixels); 636 SDL_free(_this->screen->pixels);
637 _this->screen->pixels = NULL; 637 _this->screen->pixels = NULL;
638 } 638 }
639 639
640 /* Free Epoc resources */ 640 /* Free Epoc resources */
641 641