comparison src/video/dga/SDL_dgavideo.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
21 */ 21 */
22 22
23 /* DGA 2.0 based SDL video driver implementation. 23 /* DGA 2.0 based SDL video driver implementation.
24 */ 24 */
25 25
26 #include <stdlib.h> 26 #include <stdio.h>
27 #include <string.h> 27
28 #include <X11/Xlib.h> 28 #include <X11/Xlib.h>
29 #include <Xext/extensions/xf86dga.h> 29 #include <Xext/extensions/xf86dga.h>
30 30
31 #ifdef HAVE_ALLOCA_H
32 #include <alloca.h>
33 #endif
34
35 #include "SDL.h" 31 #include "SDL.h"
32 #include "SDL_stdlib.h"
33 #include "SDL_string.h"
36 #include "SDL_error.h" 34 #include "SDL_error.h"
37 #include "SDL_video.h" 35 #include "SDL_video.h"
38 #include "SDL_mouse.h" 36 #include "SDL_mouse.h"
39 #include "SDL_sysvideo.h" 37 #include "SDL_sysvideo.h"
40 #include "SDL_pixels_c.h" 38 #include "SDL_pixels_c.h"
388 return(-1); 386 return(-1);
389 } 387 }
390 388
391 /* Query for the list of available video modes */ 389 /* Query for the list of available video modes */
392 modes = SDL_NAME(XDGAQueryModes)(DGA_Display, DGA_Screen, &num_modes); 390 modes = SDL_NAME(XDGAQueryModes)(DGA_Display, DGA_Screen, &num_modes);
393 qsort(modes, num_modes, sizeof *modes, cmpmodes); 391 SDL_qsort(modes, num_modes, sizeof *modes, cmpmodes);
394 for ( i=0; i<num_modes; ++i ) { 392 for ( i=0; i<num_modes; ++i ) {
395 #ifdef DGA_DEBUG 393 #ifdef DGA_DEBUG
396 PrintMode(&modes[i]); 394 PrintMode(&modes[i]);
397 #endif 395 #endif
398 if ( (modes[i].visualClass == PseudoColor) || 396 if ( (modes[i].visualClass == PseudoColor) ||
447 DGA_colormap = 0; 445 DGA_colormap = 0;
448 } 446 }
449 447
450 /* Search for a matching video mode */ 448 /* Search for a matching video mode */
451 modes = SDL_NAME(XDGAQueryModes)(DGA_Display, DGA_Screen, &num_modes); 449 modes = SDL_NAME(XDGAQueryModes)(DGA_Display, DGA_Screen, &num_modes);
452 qsort(modes, num_modes, sizeof *modes, cmpmodes); 450 SDL_qsort(modes, num_modes, sizeof *modes, cmpmodes);
453 for ( i=0; i<num_modes; ++i ) { 451 for ( i=0; i<num_modes; ++i ) {
454 int depth; 452 int depth;
455 453
456 454
457 depth = modes[i].depth; 455 depth = modes[i].depth;
966 964
967 /* This happens on initialization */ 965 /* This happens on initialization */
968 if ( ! DGA_colormap ) { 966 if ( ! DGA_colormap ) {
969 return(0); 967 return(0);
970 } 968 }
971 xcmap = (XColor *)alloca(ncolors*sizeof(*xcmap)); 969 xcmap = SDL_stack_alloc(XColor, ncolors);
972 for ( i=0; i<ncolors; ++i ) { 970 for ( i=0; i<ncolors; ++i ) {
973 xcmap[i].pixel = firstcolor + i; 971 xcmap[i].pixel = firstcolor + i;
974 xcmap[i].red = (colors[i].r<<8)|colors[i].r; 972 xcmap[i].red = (colors[i].r<<8)|colors[i].r;
975 xcmap[i].green = (colors[i].g<<8)|colors[i].g; 973 xcmap[i].green = (colors[i].g<<8)|colors[i].g;
976 xcmap[i].blue = (colors[i].b<<8)|colors[i].b; 974 xcmap[i].blue = (colors[i].b<<8)|colors[i].b;
978 } 976 }
979 LOCK_DISPLAY(); 977 LOCK_DISPLAY();
980 pXStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors); 978 pXStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
981 pXSync(DGA_Display, False); 979 pXSync(DGA_Display, False);
982 UNLOCK_DISPLAY(); 980 UNLOCK_DISPLAY();
981 SDL_stack_free(xcmap);
983 982
984 /* That was easy. :) */ 983 /* That was easy. :) */
985 return(1); 984 return(1);
986 } 985 }
987 986