comparison src/video/ipod/SDL_ipodvideo.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
1 #include <sys/types.h> 1 #include <sys/types.h>
2 #include <sys/ioctl.h> 2 #include <sys/ioctl.h>
3 3
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <unistd.h> 4 #include <unistd.h>
7 #include <fcntl.h> 5 #include <fcntl.h>
8 #include <string.h> 6 #include <string.h>
9 #include <termios.h> 7 #include <termios.h>
10 #include <ctype.h> 8 #include <ctype.h>
13 #include <linux/kd.h> 11 #include <linux/kd.h>
14 #include <linux/keyboard.h> 12 #include <linux/keyboard.h>
15 #include <linux/fb.h> 13 #include <linux/fb.h>
16 14
17 #include "SDL.h" 15 #include "SDL.h"
16 #include "SDL_stdlib.h"
17 #include "SDL_string.h"
18 #include "SDL_error.h" 18 #include "SDL_error.h"
19 #include "SDL_video.h" 19 #include "SDL_video.h"
20 #include "SDL_mouse.h" 20 #include "SDL_mouse.h"
21 #include "SDL_sysvideo.h" 21 #include "SDL_sysvideo.h"
22 #include "SDL_pixels_c.h" 22 #include "SDL_pixels_c.h"
91 91
92 static SDL_VideoDevice *iPod_CreateDevice (int devindex) 92 static SDL_VideoDevice *iPod_CreateDevice (int devindex)
93 { 93 {
94 SDL_VideoDevice *this; 94 SDL_VideoDevice *this;
95 95
96 this = (SDL_VideoDevice *)malloc (sizeof(SDL_VideoDevice)); 96 this = (SDL_VideoDevice *)SDL_malloc (sizeof(SDL_VideoDevice));
97 if (this) { 97 if (this) {
98 memset (this, 0, sizeof *this); 98 memset (this, 0, sizeof *this);
99 this->hidden = (struct SDL_PrivateVideoData *) malloc (sizeof(struct SDL_PrivateVideoData)); 99 this->hidden = (struct SDL_PrivateVideoData *) SDL_malloc (sizeof(struct SDL_PrivateVideoData));
100 } 100 }
101 if (!this || !this->hidden) { 101 if (!this || !this->hidden) {
102 SDL_OutOfMemory(); 102 SDL_OutOfMemory();
103 if (this) 103 if (this)
104 free (this); 104 SDL_free (this);
105 return 0; 105 return 0;
106 } 106 }
107 memset (this->hidden, 0, sizeof(struct SDL_PrivateVideoData)); 107 memset (this->hidden, 0, sizeof(struct SDL_PrivateVideoData));
108 108
109 generation = iPod_GetGeneration(); 109 generation = iPod_GetGeneration();
176 176
177 if ( (geteuid() == 0) && (curvt > 0) ) { 177 if ( (geteuid() == 0) && (curvt > 0) ) {
178 for ( i=0; vcs[i] && (kbfd < 0); ++i ) { 178 for ( i=0; vcs[i] && (kbfd < 0); ++i ) {
179 char vtpath[12]; 179 char vtpath[12];
180 180
181 sprintf(vtpath, vcs[i], curvt); 181 SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i], curvt);
182 kbfd = open(vtpath, O_RDWR); 182 kbfd = open(vtpath, O_RDWR);
183 } 183 }
184 } 184 }
185 if ( kbfd < 0 ) { 185 if ( kbfd < 0 ) {
186 if (dbgout) fprintf (dbgout, "Couldn't open any VC\n"); 186 if (dbgout) fprintf (dbgout, "Couldn't open any VC\n");
318 Bmask = 0x001F; 318 Bmask = 0x001F;
319 } else { 319 } else {
320 Rmask = Gmask = Bmask = 0; 320 Rmask = Gmask = Bmask = 0;
321 } 321 }
322 322
323 if (this->hidden->buffer) free (this->hidden->buffer); 323 if (this->hidden->buffer) SDL_free (this->hidden->buffer);
324 this->hidden->buffer = malloc (width * height * (bpp / 8)); 324 this->hidden->buffer = SDL_malloc (width * height * (bpp / 8));
325 if (!this->hidden->buffer) { 325 if (!this->hidden->buffer) {
326 SDL_SetError ("Couldn't allocate buffer for requested mode"); 326 SDL_SetError ("Couldn't allocate buffer for requested mode");
327 return 0; 327 return 0;
328 } 328 }
329 329
330 memset (this->hidden->buffer, 0, width * height * (bpp / 8)); 330 memset (this->hidden->buffer, 0, width * height * (bpp / 8));
331 331
332 if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, 0)) { 332 if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, 0)) {
333 SDL_SetError ("Couldn't allocate new pixel format"); 333 SDL_SetError ("Couldn't allocate new pixel format");
334 free (this->hidden->buffer); 334 SDL_free (this->hidden->buffer);
335 this->hidden->buffer = 0; 335 this->hidden->buffer = 0;
336 return 0; 336 return 0;
337 } 337 }
338 338
339 if (bpp <= 8) { 339 if (bpp <= 8) {