Mercurial > sdl-ios-xcode
comparison src/video/dga/SDL_dgavideo.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 |
---|---|
76 | 76 |
77 /* The driver is available is available if the display is local | 77 /* The driver is available is available if the display is local |
78 and the DGA 2.0+ extension is available, and we can map mem. | 78 and the DGA 2.0+ extension is available, and we can map mem. |
79 */ | 79 */ |
80 if ( SDL_X11_LoadSymbols() ) { | 80 if ( SDL_X11_LoadSymbols() ) { |
81 if ( (strncmp(pXDisplayName(display), ":", 1) == 0) || | 81 if ( (SDL_strncmp(pXDisplayName(display), ":", 1) == 0) || |
82 (strncmp(pXDisplayName(display), "unix:", 5) == 0) ) { | 82 (SDL_strncmp(pXDisplayName(display), "unix:", 5) == 0) ) { |
83 dpy = pXOpenDisplay(display); | 83 dpy = pXOpenDisplay(display); |
84 if ( dpy ) { | 84 if ( dpy ) { |
85 int events, errors, major, minor; | 85 int events, errors, major, minor; |
86 | 86 |
87 if ( SDL_NAME(XDGAQueryExtension)(dpy, &events, &errors) && | 87 if ( SDL_NAME(XDGAQueryExtension)(dpy, &events, &errors) && |
104 } | 104 } |
105 | 105 |
106 static void DGA_DeleteDevice(SDL_VideoDevice *device) | 106 static void DGA_DeleteDevice(SDL_VideoDevice *device) |
107 { | 107 { |
108 if (device != NULL) { | 108 if (device != NULL) { |
109 free(device->hidden); | 109 SDL_free(device->hidden); |
110 free(device); | 110 SDL_free(device); |
111 SDL_X11_UnloadSymbols(); | 111 SDL_X11_UnloadSymbols(); |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 static SDL_VideoDevice *DGA_CreateDevice(int devindex) | 115 static SDL_VideoDevice *DGA_CreateDevice(int devindex) |
116 { | 116 { |
117 SDL_VideoDevice *device = NULL; | 117 SDL_VideoDevice *device = NULL; |
118 | 118 |
119 /* Initialize all variables that we clean on shutdown */ | 119 /* Initialize all variables that we clean on shutdown */ |
120 if (SDL_X11_LoadSymbols()) { | 120 if (SDL_X11_LoadSymbols()) { |
121 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); | 121 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); |
122 if ( device ) { | 122 if ( device ) { |
123 memset(device, 0, (sizeof *device)); | 123 SDL_memset(device, 0, (sizeof *device)); |
124 device->hidden = (struct SDL_PrivateVideoData *) | 124 device->hidden = (struct SDL_PrivateVideoData *) |
125 malloc((sizeof *device->hidden)); | 125 SDL_malloc((sizeof *device->hidden)); |
126 } | 126 } |
127 if ( (device == NULL) || (device->hidden == NULL) ) { | 127 if ( (device == NULL) || (device->hidden == NULL) ) { |
128 SDL_OutOfMemory(); | 128 SDL_OutOfMemory(); |
129 if ( device ) { | 129 if ( device ) { |
130 free(device); | 130 SDL_free(device); |
131 } | 131 } |
132 SDL_X11_UnloadSymbols(); | 132 SDL_X11_UnloadSymbols(); |
133 return(0); | 133 return(0); |
134 } | 134 } |
135 memset(device->hidden, 0, (sizeof *device->hidden)); | 135 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); |
136 | 136 |
137 /* Set the function pointers */ | 137 /* Set the function pointers */ |
138 device->VideoInit = DGA_VideoInit; | 138 device->VideoInit = DGA_VideoInit; |
139 device->ListModes = DGA_ListModes; | 139 device->ListModes = DGA_ListModes; |
140 device->SetVideoMode = DGA_SetVideoMode; | 140 device->SetVideoMode = DGA_SetVideoMode; |
188 return(0); | 188 return(0); |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
192 /* Set up the new video mode rectangle */ | 192 /* Set up the new video mode rectangle */ |
193 mode = (SDL_Rect *)malloc(sizeof *mode); | 193 mode = (SDL_Rect *)SDL_malloc(sizeof *mode); |
194 if ( mode == NULL ) { | 194 if ( mode == NULL ) { |
195 SDL_OutOfMemory(); | 195 SDL_OutOfMemory(); |
196 return(-1); | 196 return(-1); |
197 } | 197 } |
198 mode->x = 0; | 198 mode->x = 0; |
201 mode->h = h; | 201 mode->h = h; |
202 | 202 |
203 /* Allocate the new list of modes, and fill in the new mode */ | 203 /* Allocate the new list of modes, and fill in the new mode */ |
204 next_mode = SDL_nummodes[index]; | 204 next_mode = SDL_nummodes[index]; |
205 SDL_modelist[index] = (SDL_Rect **) | 205 SDL_modelist[index] = (SDL_Rect **) |
206 realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); | 206 SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); |
207 if ( SDL_modelist[index] == NULL ) { | 207 if ( SDL_modelist[index] == NULL ) { |
208 SDL_OutOfMemory(); | 208 SDL_OutOfMemory(); |
209 SDL_nummodes[index] = 0; | 209 SDL_nummodes[index] = 0; |
210 free(mode); | 210 SDL_free(mode); |
211 return(-1); | 211 return(-1); |
212 } | 212 } |
213 SDL_modelist[index][next_mode] = mode; | 213 SDL_modelist[index][next_mode] = mode; |
214 SDL_modelist[index][next_mode+1] = NULL; | 214 SDL_modelist[index][next_mode+1] = NULL; |
215 SDL_nummodes[index]++; | 215 SDL_nummodes[index]++; |
231 mem = (unsigned long)SDL_NAME(XDGAGetMappedMemory)(DGA_Screen); | 231 mem = (unsigned long)SDL_NAME(XDGAGetMappedMemory)(DGA_Screen); |
232 size = 0; | 232 size = 0; |
233 proc = fopen("/proc/self/maps", "r"); | 233 proc = fopen("/proc/self/maps", "r"); |
234 if ( proc ) { | 234 if ( proc ) { |
235 while ( fgets(line, sizeof(line)-1, proc) ) { | 235 while ( fgets(line, sizeof(line)-1, proc) ) { |
236 sscanf(line, "%x-%x", &start, &stop); | 236 SDL_sscanf(line, "%x-%x", &start, &stop); |
237 if ( start == mem ) { | 237 if ( start == mem ) { |
238 size = (Uint32)((stop-start)/1024); | 238 size = (Uint32)((stop-start)/1024); |
239 break; | 239 break; |
240 } | 240 } |
241 } | 241 } |
603 | 603 |
604 surfaces_memtotal = size; | 604 surfaces_memtotal = size; |
605 surfaces_memleft = size; | 605 surfaces_memleft = size; |
606 | 606 |
607 if ( surfaces_memleft > 0 ) { | 607 if ( surfaces_memleft > 0 ) { |
608 bucket = (vidmem_bucket *)malloc(sizeof(*bucket)); | 608 bucket = (vidmem_bucket *)SDL_malloc(sizeof(*bucket)); |
609 if ( bucket == NULL ) { | 609 if ( bucket == NULL ) { |
610 SDL_OutOfMemory(); | 610 SDL_OutOfMemory(); |
611 return(-1); | 611 return(-1); |
612 } | 612 } |
613 bucket->prev = &surfaces; | 613 bucket->prev = &surfaces; |
635 | 635 |
636 bucket = surfaces.next; | 636 bucket = surfaces.next; |
637 while ( bucket ) { | 637 while ( bucket ) { |
638 freeable = bucket; | 638 freeable = bucket; |
639 bucket = bucket->next; | 639 bucket = bucket->next; |
640 free(freeable); | 640 SDL_free(freeable); |
641 } | 641 } |
642 surfaces.next = NULL; | 642 surfaces.next = NULL; |
643 } | 643 } |
644 | 644 |
645 static __inline__ void DGA_AddBusySurface(SDL_Surface *surface) | 645 static __inline__ void DGA_AddBusySurface(SDL_Surface *surface) |
712 vidmem_bucket *newbucket; | 712 vidmem_bucket *newbucket; |
713 | 713 |
714 #ifdef DGA_DEBUG | 714 #ifdef DGA_DEBUG |
715 fprintf(stderr, "Adding new free bucket of %d bytes\n", extra); | 715 fprintf(stderr, "Adding new free bucket of %d bytes\n", extra); |
716 #endif | 716 #endif |
717 newbucket = (vidmem_bucket *)malloc(sizeof(*newbucket)); | 717 newbucket = (vidmem_bucket *)SDL_malloc(sizeof(*newbucket)); |
718 if ( newbucket == NULL ) { | 718 if ( newbucket == NULL ) { |
719 SDL_OutOfMemory(); | 719 SDL_OutOfMemory(); |
720 retval = -1; | 720 retval = -1; |
721 goto done; | 721 goto done; |
722 } | 722 } |
773 bucket->size += bucket->next->size; | 773 bucket->size += bucket->next->size; |
774 bucket->next = bucket->next->next; | 774 bucket->next = bucket->next->next; |
775 if ( bucket->next ) { | 775 if ( bucket->next ) { |
776 bucket->next->prev = bucket; | 776 bucket->next->prev = bucket; |
777 } | 777 } |
778 free(freeable); | 778 SDL_free(freeable); |
779 } | 779 } |
780 if ( bucket->prev && ! bucket->prev->used ) { | 780 if ( bucket->prev && ! bucket->prev->used ) { |
781 #ifdef DGA_DEBUG | 781 #ifdef DGA_DEBUG |
782 printf("Merging with previous bucket, for %d total bytes\n", bucket->prev->size+bucket->size); | 782 printf("Merging with previous bucket, for %d total bytes\n", bucket->prev->size+bucket->size); |
783 #endif | 783 #endif |
785 bucket->prev->size += bucket->size; | 785 bucket->prev->size += bucket->size; |
786 bucket->prev->next = bucket->next; | 786 bucket->prev->next = bucket->next; |
787 if ( bucket->next ) { | 787 if ( bucket->next ) { |
788 bucket->next->prev = bucket->prev; | 788 bucket->next->prev = bucket->prev; |
789 } | 789 } |
790 free(freeable); | 790 SDL_free(freeable); |
791 } | 791 } |
792 } | 792 } |
793 surface->pixels = NULL; | 793 surface->pixels = NULL; |
794 surface->hwdata = NULL; | 794 surface->hwdata = NULL; |
795 } | 795 } |
1051 | 1051 |
1052 /* Clean up defined video modes */ | 1052 /* Clean up defined video modes */ |
1053 for ( i=0; i<NUM_MODELISTS; ++i ) { | 1053 for ( i=0; i<NUM_MODELISTS; ++i ) { |
1054 if ( SDL_modelist[i] != NULL ) { | 1054 if ( SDL_modelist[i] != NULL ) { |
1055 for ( j=0; SDL_modelist[i][j]; ++j ) { | 1055 for ( j=0; SDL_modelist[i][j]; ++j ) { |
1056 free(SDL_modelist[i][j]); | 1056 SDL_free(SDL_modelist[i][j]); |
1057 } | 1057 } |
1058 free(SDL_modelist[i]); | 1058 SDL_free(SDL_modelist[i]); |
1059 SDL_modelist[i] = NULL; | 1059 SDL_modelist[i] = NULL; |
1060 } | 1060 } |
1061 } | 1061 } |
1062 | 1062 |
1063 /* Clean up the memory bucket list */ | 1063 /* Clean up the memory bucket list */ |