Commit 0526b1fc authored by Sam Lantinga's avatar Sam Lantinga

Using the SDL C runtime functions

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401715
parent d8aace2c
...@@ -117,14 +117,14 @@ static SDL_VideoDevice* QZ_CreateDevice (int device_index) { ...@@ -117,14 +117,14 @@ static SDL_VideoDevice* QZ_CreateDevice (int device_index) {
SDL_VideoDevice *device; SDL_VideoDevice *device;
SDL_PrivateVideoData *hidden; SDL_PrivateVideoData *hidden;
device = (SDL_VideoDevice*) malloc (sizeof (*device) ); device = (SDL_VideoDevice*) SDL_malloc (sizeof (*device) );
hidden = (SDL_PrivateVideoData*) malloc (sizeof (*hidden) ); hidden = (SDL_PrivateVideoData*) SDL_malloc (sizeof (*hidden) );
if (device == NULL || hidden == NULL) if (device == NULL || hidden == NULL)
SDL_OutOfMemory (); SDL_OutOfMemory ();
memset (device, 0, sizeof (*device) ); SDL_memset (device, 0, sizeof (*device) );
memset (hidden, 0, sizeof (*hidden) ); SDL_memset (hidden, 0, sizeof (*hidden) );
device->hidden = hidden; device->hidden = hidden;
...@@ -178,8 +178,8 @@ static SDL_VideoDevice* QZ_CreateDevice (int device_index) { ...@@ -178,8 +178,8 @@ static SDL_VideoDevice* QZ_CreateDevice (int device_index) {
static void QZ_DeleteDevice (SDL_VideoDevice *device) { static void QZ_DeleteDevice (SDL_VideoDevice *device) {
free (device->hidden); SDL_free (device->hidden);
free (device); SDL_free (device);
} }
static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) { static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) {
...@@ -242,9 +242,9 @@ static SDL_Rect** QZ_ListModes (_THIS, SDL_PixelFormat *format, Uint32 flags) { ...@@ -242,9 +242,9 @@ static SDL_Rect** QZ_ListModes (_THIS, SDL_PixelFormat *format, Uint32 flags) {
int i; int i;
for (i = 0; client_mode_list[i] != NULL; i++) for (i = 0; client_mode_list[i] != NULL; i++)
free (client_mode_list[i]); SDL_free (client_mode_list[i]);
free (client_mode_list); SDL_free (client_mode_list);
client_mode_list = NULL; client_mode_list = NULL;
} }
...@@ -297,12 +297,12 @@ static SDL_Rect** QZ_ListModes (_THIS, SDL_PixelFormat *format, Uint32 flags) { ...@@ -297,12 +297,12 @@ static SDL_Rect** QZ_ListModes (_THIS, SDL_PixelFormat *format, Uint32 flags) {
if (client_mode_list == NULL) if (client_mode_list == NULL)
client_mode_list = (SDL_Rect**) client_mode_list = (SDL_Rect**)
malloc (sizeof(*client_mode_list) * (list_size+1) ); SDL_malloc (sizeof(*client_mode_list) * (list_size+1) );
else else
client_mode_list = (SDL_Rect**) client_mode_list = (SDL_Rect**)
realloc (client_mode_list, sizeof(*client_mode_list) * (list_size+1)); SDL_realloc (client_mode_list, sizeof(*client_mode_list) * (list_size+1));
rect = (SDL_Rect*) malloc (sizeof(**client_mode_list)); rect = (SDL_Rect*) SDL_malloc (sizeof(**client_mode_list));
if (client_mode_list == NULL || rect == NULL) { if (client_mode_list == NULL || rect == NULL) {
SDL_OutOfMemory (); SDL_OutOfMemory ();
...@@ -372,7 +372,7 @@ static void QZ_UnsetVideoMode (_THIS, BOOL to_desktop) { ...@@ -372,7 +372,7 @@ static void QZ_UnsetVideoMode (_THIS, BOOL to_desktop) {
SDL_WaitThread (thread, NULL); SDL_WaitThread (thread, NULL);
SDL_DestroySemaphore (sem1); SDL_DestroySemaphore (sem1);
SDL_DestroySemaphore (sem2); SDL_DestroySemaphore (sem2);
free (sw_buffers[0]); SDL_free (sw_buffers[0]);
} }
/* /*
...@@ -493,7 +493,7 @@ static SDL_Surface* QZ_SetVideoFullScreen (_THIS, SDL_Surface *current, int widt ...@@ -493,7 +493,7 @@ static SDL_Surface* QZ_SetVideoFullScreen (_THIS, SDL_Surface *current, int widt
this->UnlockHWSurface = QZ_UnlockDoubleBuffer; this->UnlockHWSurface = QZ_UnlockDoubleBuffer;
this->FlipHWSurface = QZ_FlipDoubleBuffer; this->FlipHWSurface = QZ_FlipDoubleBuffer;
current->pixels = malloc (current->pitch * current->h * 2); current->pixels = SDL_malloc (current->pitch * current->h * 2);
if (current->pixels == NULL) { if (current->pixels == NULL) {
SDL_OutOfMemory (); SDL_OutOfMemory ();
goto ERR_DOUBLEBUF; goto ERR_DOUBLEBUF;
...@@ -984,7 +984,7 @@ static int QZ_ThreadFlip (_THIS) { ...@@ -984,7 +984,7 @@ static int QZ_ThreadFlip (_THIS) {
while ( h-- ) { while ( h-- ) {
memcpy (dst, src, len); SDL_memcpy (dst, src, len);
src += skip; src += skip;
dst += skip; dst += skip;
} }
...@@ -1211,7 +1211,7 @@ static int QZ_IsWindowObscured (NSWindow *window) { ...@@ -1211,7 +1211,7 @@ static int QZ_IsWindowObscured (NSWindow *window) {
dockIconCacheMiss) { dockIconCacheMiss) {
numCachedDockIcons = i - firstDockIcon; numCachedDockIcons = i - firstDockIcon;
memcpy (dockIcons, &(windows[firstDockIcon]), SDL_memcpy (dockIcons, &(windows[firstDockIcon]),
numCachedDockIcons * sizeof(*windows)); numCachedDockIcons * sizeof(*windows));
} }
......
...@@ -41,12 +41,12 @@ WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask, ...@@ -41,12 +41,12 @@ WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask,
int row, bytes; int row, bytes;
/* Allocate the cursor memory */ /* Allocate the cursor memory */
cursor = (WMcursor *)malloc(sizeof(WMcursor)); cursor = (WMcursor *)SDL_malloc(sizeof(WMcursor));
if ( cursor == NULL ) { if ( cursor == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(NULL); return(NULL);
} }
memset(cursor, 0, sizeof(*cursor)); SDL_memset(cursor, 0, sizeof(*cursor));
if (w > 16) if (w > 16)
w = 16; w = 16;
...@@ -57,11 +57,11 @@ WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask, ...@@ -57,11 +57,11 @@ WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask,
bytes = (w+7)/8; bytes = (w+7)/8;
for ( row=0; row<h; ++row ) { for ( row=0; row<h; ++row ) {
memcpy(&cursor->curs.data[row], data, bytes); SDL_memcpy(&cursor->curs.data[row], data, bytes);
data += bytes; data += bytes;
} }
for ( row=0; row<h; ++row ) { for ( row=0; row<h; ++row ) {
memcpy(&cursor->curs.mask[row], mask, bytes); SDL_memcpy(&cursor->curs.mask[row], mask, bytes);
mask += bytes; mask += bytes;
} }
cursor->curs.hotSpot.h = hot_x; cursor->curs.hotSpot.h = hot_x;
......
...@@ -91,16 +91,16 @@ static void QZ_FreeHWYUV (_THIS, SDL_Overlay *overlay) { ...@@ -91,16 +91,16 @@ static void QZ_FreeHWYUV (_THIS, SDL_Overlay *overlay) {
CDSequenceEnd (yuv_seq); CDSequenceEnd (yuv_seq);
ExitMovies(); ExitMovies();
free (overlay->hwfuncs); SDL_free (overlay->hwfuncs);
free (overlay->pitches); SDL_free (overlay->pitches);
free (overlay->pixels); SDL_free (overlay->pixels);
if (SDL_VideoSurface->flags & SDL_FULLSCREEN) { if (SDL_VideoSurface->flags & SDL_FULLSCREEN) {
[ qz_window close ]; [ qz_window close ];
qz_window = nil; qz_window = nil;
} }
free (yuv_matrix); SDL_free (yuv_matrix);
DisposeHandle ((Handle)yuv_idh); DisposeHandle ((Handle)yuv_idh);
} }
...@@ -134,7 +134,7 @@ SDL_Overlay* QZ_CreateYUVOverlay (_THIS, int width, int height, ...@@ -134,7 +134,7 @@ SDL_Overlay* QZ_CreateYUVOverlay (_THIS, int width, int height,
return NULL; return NULL;
} }
yuv_matrix = (MatrixRecordPtr) malloc (sizeof(MatrixRecord)); yuv_matrix = (MatrixRecordPtr) SDL_malloc (sizeof(MatrixRecord));
if (yuv_matrix == NULL) { if (yuv_matrix == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return NULL; return NULL;
...@@ -234,7 +234,7 @@ SDL_Overlay* QZ_CreateYUVOverlay (_THIS, int width, int height, ...@@ -234,7 +234,7 @@ SDL_Overlay* QZ_CreateYUVOverlay (_THIS, int width, int height,
return NULL; return NULL;
} }
overlay = (SDL_Overlay*) malloc (sizeof(*overlay)); overlay = (SDL_Overlay*) SDL_malloc (sizeof(*overlay));
if (overlay == NULL) { if (overlay == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return NULL; return NULL;
...@@ -267,15 +267,15 @@ SDL_Overlay* QZ_CreateYUVOverlay (_THIS, int width, int height, ...@@ -267,15 +267,15 @@ SDL_Overlay* QZ_CreateYUVOverlay (_THIS, int width, int height,
return NULL; return NULL;
} }
pixels = (Uint8**) malloc (sizeof(*pixels) * 3); pixels = (Uint8**) SDL_malloc (sizeof(*pixels) * 3);
pitches = (Uint16*) malloc (sizeof(*pitches) * 3); pitches = (Uint16*) SDL_malloc (sizeof(*pitches) * 3);
if (pixels == NULL || pitches == NULL) { if (pixels == NULL || pitches == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return NULL; return NULL;
} }
yuv_pixmap = (PlanarPixmapInfoYUV420*) yuv_pixmap = (PlanarPixmapInfoYUV420*)
malloc (sizeof(PlanarPixmapInfoYUV420) + SDL_malloc (sizeof(PlanarPixmapInfoYUV420) +
(width * height * 2)); (width * height * 2));
if (yuv_pixmap == NULL) { if (yuv_pixmap == NULL) {
SDL_OutOfMemory (); SDL_OutOfMemory ();
...@@ -310,7 +310,7 @@ SDL_Overlay* QZ_CreateYUVOverlay (_THIS, int width, int height, ...@@ -310,7 +310,7 @@ SDL_Overlay* QZ_CreateYUVOverlay (_THIS, int width, int height,
overlay->pitches = pitches; overlay->pitches = pitches;
} }
overlay->hwfuncs = malloc (sizeof(*overlay->hwfuncs)); overlay->hwfuncs = SDL_malloc (sizeof(*overlay->hwfuncs));
if (overlay->hwfuncs == NULL) { if (overlay->hwfuncs == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return NULL; return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment