From aa489f3306e1b853b85a84821c830bfa647f9536 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 1 May 2006 11:07:04 +0000 Subject: [PATCH] Using the SDL C runtime functions --- src/video/quartz/SDL_QuartzVideo.m | 30 +++++++++++++++--------------- src/video/quartz/SDL_QuartzWM.m | 8 ++++---- src/video/quartz/SDL_QuartzYUV.m | 20 ++++++++++---------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/video/quartz/SDL_QuartzVideo.m b/src/video/quartz/SDL_QuartzVideo.m index 1010473aa..8d41169ce 100644 --- a/src/video/quartz/SDL_QuartzVideo.m +++ b/src/video/quartz/SDL_QuartzVideo.m @@ -117,14 +117,14 @@ static int QZ_Available () { SDL_VideoDevice *device; SDL_PrivateVideoData *hidden; - device = (SDL_VideoDevice*) malloc (sizeof (*device) ); - hidden = (SDL_PrivateVideoData*) malloc (sizeof (*hidden) ); + device = (SDL_VideoDevice*) SDL_malloc (sizeof (*device) ); + hidden = (SDL_PrivateVideoData*) SDL_malloc (sizeof (*hidden) ); if (device == NULL || hidden == NULL) SDL_OutOfMemory (); - memset (device, 0, sizeof (*device) ); - memset (hidden, 0, sizeof (*hidden) ); + SDL_memset (device, 0, sizeof (*device) ); + SDL_memset (hidden, 0, sizeof (*hidden) ); device->hidden = hidden; @@ -178,8 +178,8 @@ static int QZ_Available () { static void QZ_DeleteDevice (SDL_VideoDevice *device) { - free (device->hidden); - free (device); + SDL_free (device->hidden); + SDL_free (device); } static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) { @@ -242,9 +242,9 @@ static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) { int 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; } @@ -297,12 +297,12 @@ static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) { if (client_mode_list == NULL) client_mode_list = (SDL_Rect**) - malloc (sizeof(*client_mode_list) * (list_size+1) ); + SDL_malloc (sizeof(*client_mode_list) * (list_size+1) ); else 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) { SDL_OutOfMemory (); @@ -372,7 +372,7 @@ static void QZ_UnsetVideoMode (_THIS, BOOL to_desktop) { SDL_WaitThread (thread, NULL); SDL_DestroySemaphore (sem1); SDL_DestroySemaphore (sem2); - free (sw_buffers[0]); + SDL_free (sw_buffers[0]); } /* @@ -493,7 +493,7 @@ other blitting while waiting on the VBL (and hence results in higher framerates) this->UnlockHWSurface = QZ_UnlockDoubleBuffer; 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) { SDL_OutOfMemory (); goto ERR_DOUBLEBUF; @@ -984,7 +984,7 @@ static int QZ_ThreadFlip (_THIS) { while ( h-- ) { - memcpy (dst, src, len); + SDL_memcpy (dst, src, len); src += skip; dst += skip; } @@ -1211,7 +1211,7 @@ they are too big (but will work) for background windows dockIconCacheMiss) { numCachedDockIcons = i - firstDockIcon; - memcpy (dockIcons, &(windows[firstDockIcon]), + SDL_memcpy (dockIcons, &(windows[firstDockIcon]), numCachedDockIcons * sizeof(*windows)); } diff --git a/src/video/quartz/SDL_QuartzWM.m b/src/video/quartz/SDL_QuartzWM.m index a3aa3ed23..b2657df28 100644 --- a/src/video/quartz/SDL_QuartzWM.m +++ b/src/video/quartz/SDL_QuartzWM.m @@ -41,12 +41,12 @@ void QZ_FreeWMCursor (_THIS, WMcursor *cursor) { int row, bytes; /* Allocate the cursor memory */ - cursor = (WMcursor *)malloc(sizeof(WMcursor)); + cursor = (WMcursor *)SDL_malloc(sizeof(WMcursor)); if ( cursor == NULL ) { SDL_OutOfMemory(); return(NULL); } - memset(cursor, 0, sizeof(*cursor)); + SDL_memset(cursor, 0, sizeof(*cursor)); if (w > 16) w = 16; @@ -57,11 +57,11 @@ void QZ_FreeWMCursor (_THIS, WMcursor *cursor) { bytes = (w+7)/8; for ( row=0; rowcurs.data[row], data, bytes); + SDL_memcpy(&cursor->curs.data[row], data, bytes); data += bytes; } for ( row=0; rowcurs.mask[row], mask, bytes); + SDL_memcpy(&cursor->curs.mask[row], mask, bytes); mask += bytes; } cursor->curs.hotSpot.h = hot_x; diff --git a/src/video/quartz/SDL_QuartzYUV.m b/src/video/quartz/SDL_QuartzYUV.m index d849686c5..96539d679 100644 --- a/src/video/quartz/SDL_QuartzYUV.m +++ b/src/video/quartz/SDL_QuartzYUV.m @@ -91,16 +91,16 @@ static void QZ_FreeHWYUV (_THIS, SDL_Overlay *overlay) { CDSequenceEnd (yuv_seq); ExitMovies(); - free (overlay->hwfuncs); - free (overlay->pitches); - free (overlay->pixels); + SDL_free (overlay->hwfuncs); + SDL_free (overlay->pitches); + SDL_free (overlay->pixels); if (SDL_VideoSurface->flags & SDL_FULLSCREEN) { [ qz_window close ]; qz_window = nil; } - free (yuv_matrix); + SDL_free (yuv_matrix); DisposeHandle ((Handle)yuv_idh); } @@ -134,7 +134,7 @@ static void QZ_FreeHWYUV (_THIS, SDL_Overlay *overlay) { return NULL; } - yuv_matrix = (MatrixRecordPtr) malloc (sizeof(MatrixRecord)); + yuv_matrix = (MatrixRecordPtr) SDL_malloc (sizeof(MatrixRecord)); if (yuv_matrix == NULL) { SDL_OutOfMemory(); return NULL; @@ -234,7 +234,7 @@ static void QZ_FreeHWYUV (_THIS, SDL_Overlay *overlay) { return NULL; } - overlay = (SDL_Overlay*) malloc (sizeof(*overlay)); + overlay = (SDL_Overlay*) SDL_malloc (sizeof(*overlay)); if (overlay == NULL) { SDL_OutOfMemory(); return NULL; @@ -267,15 +267,15 @@ static void QZ_FreeHWYUV (_THIS, SDL_Overlay *overlay) { return NULL; } - pixels = (Uint8**) malloc (sizeof(*pixels) * 3); - pitches = (Uint16*) malloc (sizeof(*pitches) * 3); + pixels = (Uint8**) SDL_malloc (sizeof(*pixels) * 3); + pitches = (Uint16*) SDL_malloc (sizeof(*pitches) * 3); if (pixels == NULL || pitches == NULL) { SDL_OutOfMemory(); return NULL; } yuv_pixmap = (PlanarPixmapInfoYUV420*) - malloc (sizeof(PlanarPixmapInfoYUV420) + + SDL_malloc (sizeof(PlanarPixmapInfoYUV420) + (width * height * 2)); if (yuv_pixmap == NULL) { SDL_OutOfMemory (); @@ -310,7 +310,7 @@ static void QZ_FreeHWYUV (_THIS, SDL_Overlay *overlay) { overlay->pitches = pitches; } - overlay->hwfuncs = malloc (sizeof(*overlay->hwfuncs)); + overlay->hwfuncs = SDL_malloc (sizeof(*overlay->hwfuncs)); if (overlay->hwfuncs == NULL) { SDL_OutOfMemory(); return NULL;