comparison src/video/directfb/SDL_DirectFB_video.c @ 1338:604d73db6802

Removed uses of stdlib.h and string.h
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 09:29:18 +0000
parents 3692456e7b0f
children c71e05b4dc2e
comparison
equal deleted inserted replaced
1337:c687f06c7473 1338:604d73db6802
25 */ 25 */
26 26
27 /* DirectFB video driver implementation. 27 /* DirectFB video driver implementation.
28 */ 28 */
29 29
30 #include <stdlib.h>
31 #include <string.h>
32 #include <stdio.h>
33 #include <fcntl.h> 30 #include <fcntl.h>
34 #include <unistd.h> 31 #include <unistd.h>
35 #include <sys/mman.h> 32 #include <sys/mman.h>
36 33
37 #include <directfb.h> 34 #include <directfb.h>
38 #include <directfb_version.h> 35 #include <directfb_version.h>
39 36
40 #include "SDL.h" 37 #include "SDL.h"
38 #include "SDL_stdlib.h"
39 #include "SDL_string.h"
41 #include "SDL_error.h" 40 #include "SDL_error.h"
42 #include "SDL_video.h" 41 #include "SDL_video.h"
43 #include "SDL_mouse.h" 42 #include "SDL_mouse.h"
44 #include "SDL_sysvideo.h" 43 #include "SDL_sysvideo.h"
45 #include "SDL_pixels_c.h" 44 #include "SDL_pixels_c.h"
108 107
109 /* Initialize all variables that we clean on shutdown */ 108 /* Initialize all variables that we clean on shutdown */
110 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); 109 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
111 if (device) 110 if (device)
112 { 111 {
113 memset (device, 0, (sizeof *device)); 112 SDL_memset (device, 0, (sizeof *device));
114 device->hidden = (struct SDL_PrivateVideoData *) malloc (sizeof (*device->hidden)); 113 device->hidden = (struct SDL_PrivateVideoData *) malloc (sizeof (*device->hidden));
115 } 114 }
116 if (device == NULL || device->hidden == NULL) 115 if (device == NULL || device->hidden == NULL)
117 { 116 {
118 SDL_OutOfMemory(); 117 SDL_OutOfMemory();
120 { 119 {
121 free (device); 120 free (device);
122 } 121 }
123 return(0); 122 return(0);
124 } 123 }
125 memset (device->hidden, 0, sizeof (*device->hidden)); 124 SDL_memset (device->hidden, 0, sizeof (*device->hidden));
126 125
127 /* Set the function pointers */ 126 /* Set the function pointers */
128 device->VideoInit = DirectFB_VideoInit; 127 device->VideoInit = DirectFB_VideoInit;
129 device->ListModes = DirectFB_ListModes; 128 device->ListModes = DirectFB_ListModes;
130 device->SetVideoMode = DirectFB_SetVideoMode; 129 device->SetVideoMode = DirectFB_SetVideoMode;
193 SDL_VideoDevice *this = (SDL_VideoDevice *)data; 192 SDL_VideoDevice *this = (SDL_VideoDevice *)data;
194 struct DirectFBEnumRect *enumrect; 193 struct DirectFBEnumRect *enumrect;
195 194
196 HIDDEN->nummodes++; 195 HIDDEN->nummodes++;
197 196
198 enumrect = calloc(1, sizeof(struct DirectFBEnumRect)); 197 enumrect = SDL_calloc(1, sizeof(struct DirectFBEnumRect));
199 if (!enumrect) 198 if (!enumrect)
200 { 199 {
201 SDL_OutOfMemory(); 200 SDL_OutOfMemory();
202 return DFENUM_CANCEL; 201 return DFENUM_CANCEL;
203 } 202 }
292 static SDL_Palette *AllocatePalette(int size) 291 static SDL_Palette *AllocatePalette(int size)
293 { 292 {
294 SDL_Palette *palette; 293 SDL_Palette *palette;
295 SDL_Color *colors; 294 SDL_Color *colors;
296 295
297 palette = calloc (1, sizeof(SDL_Palette)); 296 palette = SDL_calloc (1, sizeof(SDL_Palette));
298 if (!palette) 297 if (!palette)
299 { 298 {
300 SDL_OutOfMemory(); 299 SDL_OutOfMemory();
301 return NULL; 300 return NULL;
302 } 301 }
303 302
304 colors = calloc (size, sizeof(SDL_Color)); 303 colors = SDL_calloc (size, sizeof(SDL_Color));
305 if (!colors) 304 if (!colors)
306 { 305 {
307 SDL_OutOfMemory(); 306 SDL_OutOfMemory();
308 return NULL; 307 return NULL;
309 } 308 }
430 { 429 {
431 SetDirectFBerror ("dfb->EnumVideoModes", ret); 430 SetDirectFBerror ("dfb->EnumVideoModes", ret);
432 goto error; 431 goto error;
433 } 432 }
434 433
435 HIDDEN->modelist = calloc (HIDDEN->nummodes + 1, sizeof(SDL_Rect *)); 434 HIDDEN->modelist = SDL_calloc (HIDDEN->nummodes + 1, sizeof(SDL_Rect *));
436 if (!HIDDEN->modelist) 435 if (!HIDDEN->modelist)
437 { 436 {
438 SDL_OutOfMemory(); 437 SDL_OutOfMemory();
439 goto error; 438 goto error;
440 } 439 }
612 } 611 }
613 } 612 }
614 else if (!current->hwdata) 613 else if (!current->hwdata)
615 { 614 {
616 /* Allocate the hardware acceleration data */ 615 /* Allocate the hardware acceleration data */
617 current->hwdata = (struct private_hwdata *) calloc (1, sizeof(*current->hwdata)); 616 current->hwdata = (struct private_hwdata *) SDL_calloc (1, sizeof(*current->hwdata));
618 if (!current->hwdata) 617 if (!current->hwdata)
619 { 618 {
620 SDL_OutOfMemory(); 619 SDL_OutOfMemory();
621 return NULL; 620 return NULL;
622 } 621 }
819 dsc.pixelformat = SDLToDFBPixelFormat (surface->format); 818 dsc.pixelformat = SDLToDFBPixelFormat (surface->format);
820 if (dsc.pixelformat == DSPF_UNKNOWN) 819 if (dsc.pixelformat == DSPF_UNKNOWN)
821 return -1; 820 return -1;
822 821
823 /* Allocate the hardware acceleration data */ 822 /* Allocate the hardware acceleration data */
824 surface->hwdata = (struct private_hwdata *) calloc (1, sizeof(*surface->hwdata)); 823 surface->hwdata = (struct private_hwdata *) SDL_calloc (1, sizeof(*surface->hwdata));
825 if (surface->hwdata == NULL) 824 if (surface->hwdata == NULL)
826 { 825 {
827 SDL_OutOfMemory(); 826 SDL_OutOfMemory();
828 return -1; 827 return -1;
829 } 828 }