Using the SDL C runtime functions
authorSam Lantinga <slouken@libsdl.org>
Mon, 01 May 2006 11:07:04 +0000
changeset 1756 eed7a3f396ce
parent 1755 91063c450171
child 1757 ac282d472a2e
Using the SDL C runtime functions
src/video/quartz/SDL_QuartzVideo.m
src/video/quartz/SDL_QuartzWM.m
src/video/quartz/SDL_QuartzYUV.m
--- a/src/video/quartz/SDL_QuartzVideo.m	Mon May 01 07:23:46 2006 +0000
+++ b/src/video/quartz/SDL_QuartzVideo.m	Mon May 01 11:07:04 2006 +0000
@@ -117,14 +117,14 @@
     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 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 @@
         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 @@
 
                 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 @@
             SDL_WaitThread (thread, NULL);
             SDL_DestroySemaphore (sem1);
             SDL_DestroySemaphore (sem2);
-            free (sw_buffers[0]);
+            SDL_free (sw_buffers[0]);
         }
         
         /* 
@@ -493,7 +493,7 @@
         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 @@
         
         while ( h-- ) {
         
-            memcpy (dst, src, len);
+            SDL_memcpy (dst, src, len);
             src += skip;
             dst += skip;
         }
@@ -1211,7 +1211,7 @@
                             dockIconCacheMiss) {
 
                             numCachedDockIcons = i - firstDockIcon;
-                            memcpy (dockIcons, &(windows[firstDockIcon]),
+                            SDL_memcpy (dockIcons, &(windows[firstDockIcon]),
                                     numCachedDockIcons * sizeof(*windows));
                         }
 
--- a/src/video/quartz/SDL_QuartzWM.m	Mon May 01 07:23:46 2006 +0000
+++ b/src/video/quartz/SDL_QuartzWM.m	Mon May 01 11:07:04 2006 +0000
@@ -41,12 +41,12 @@
     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 @@
     bytes = (w+7)/8;
 
     for ( row=0; row<h; ++row ) {
-        memcpy(&cursor->curs.data[row], data, bytes);
+        SDL_memcpy(&cursor->curs.data[row], data, bytes);
         data += bytes;
     }
     for ( row=0; row<h; ++row ) {
-        memcpy(&cursor->curs.mask[row], mask, bytes);
+        SDL_memcpy(&cursor->curs.mask[row], mask, bytes);
         mask += bytes;
     }
     cursor->curs.hotSpot.h = hot_x;
--- a/src/video/quartz/SDL_QuartzYUV.m	Mon May 01 07:23:46 2006 +0000
+++ b/src/video/quartz/SDL_QuartzYUV.m	Mon May 01 11:07:04 2006 +0000
@@ -91,16 +91,16 @@
     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 @@
         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 @@
         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 @@
             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 @@
         overlay->pitches = pitches;
     }
 
-    overlay->hwfuncs = malloc (sizeof(*overlay->hwfuncs));
+    overlay->hwfuncs = SDL_malloc (sizeof(*overlay->hwfuncs));
     if (overlay->hwfuncs == NULL) {
         SDL_OutOfMemory();
         return NULL;