Using the SDL C runtime functions
authorSam Lantinga <slouken@libsdl.org>
Mon, 01 May 2006 11:07:04 +0000
changeset 1756eed7a3f396ce
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
     1.1 --- a/src/video/quartz/SDL_QuartzVideo.m	Mon May 01 07:23:46 2006 +0000
     1.2 +++ b/src/video/quartz/SDL_QuartzVideo.m	Mon May 01 11:07:04 2006 +0000
     1.3 @@ -117,14 +117,14 @@
     1.4      SDL_VideoDevice *device;
     1.5      SDL_PrivateVideoData *hidden;
     1.6  
     1.7 -    device = (SDL_VideoDevice*) malloc (sizeof (*device) );
     1.8 -    hidden = (SDL_PrivateVideoData*) malloc (sizeof (*hidden) );
     1.9 +    device = (SDL_VideoDevice*) SDL_malloc (sizeof (*device) );
    1.10 +    hidden = (SDL_PrivateVideoData*) SDL_malloc (sizeof (*hidden) );
    1.11  
    1.12      if (device == NULL || hidden == NULL)
    1.13          SDL_OutOfMemory ();
    1.14  
    1.15 -    memset (device, 0, sizeof (*device) );
    1.16 -    memset (hidden, 0, sizeof (*hidden) );
    1.17 +    SDL_memset (device, 0, sizeof (*device) );
    1.18 +    SDL_memset (hidden, 0, sizeof (*hidden) );
    1.19  
    1.20      device->hidden = hidden;
    1.21  
    1.22 @@ -178,8 +178,8 @@
    1.23  
    1.24  static void QZ_DeleteDevice (SDL_VideoDevice *device) {
    1.25  
    1.26 -    free (device->hidden);
    1.27 -    free (device);
    1.28 +    SDL_free (device->hidden);
    1.29 +    SDL_free (device);
    1.30  }
    1.31  
    1.32  static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) {
    1.33 @@ -242,9 +242,9 @@
    1.34          int i;
    1.35  
    1.36          for (i = 0; client_mode_list[i] != NULL; i++)
    1.37 -            free (client_mode_list[i]);
    1.38 +            SDL_free (client_mode_list[i]);
    1.39  
    1.40 -        free (client_mode_list);
    1.41 +        SDL_free (client_mode_list);
    1.42          client_mode_list = NULL;
    1.43      }
    1.44  
    1.45 @@ -297,12 +297,12 @@
    1.46  
    1.47                  if (client_mode_list == NULL)
    1.48                      client_mode_list = (SDL_Rect**) 
    1.49 -                        malloc (sizeof(*client_mode_list) * (list_size+1) );
    1.50 +                        SDL_malloc (sizeof(*client_mode_list) * (list_size+1) );
    1.51                  else
    1.52                      client_mode_list = (SDL_Rect**) 
    1.53 -                        realloc (client_mode_list, sizeof(*client_mode_list) * (list_size+1));
    1.54 +                        SDL_realloc (client_mode_list, sizeof(*client_mode_list) * (list_size+1));
    1.55  
    1.56 -                rect = (SDL_Rect*) malloc (sizeof(**client_mode_list));
    1.57 +                rect = (SDL_Rect*) SDL_malloc (sizeof(**client_mode_list));
    1.58  
    1.59                  if (client_mode_list == NULL || rect == NULL) {
    1.60                      SDL_OutOfMemory ();
    1.61 @@ -372,7 +372,7 @@
    1.62              SDL_WaitThread (thread, NULL);
    1.63              SDL_DestroySemaphore (sem1);
    1.64              SDL_DestroySemaphore (sem2);
    1.65 -            free (sw_buffers[0]);
    1.66 +            SDL_free (sw_buffers[0]);
    1.67          }
    1.68          
    1.69          /* 
    1.70 @@ -493,7 +493,7 @@
    1.71          this->UnlockHWSurface = QZ_UnlockDoubleBuffer;
    1.72          this->FlipHWSurface = QZ_FlipDoubleBuffer;
    1.73  
    1.74 -        current->pixels = malloc (current->pitch * current->h * 2);
    1.75 +        current->pixels = SDL_malloc (current->pitch * current->h * 2);
    1.76          if (current->pixels == NULL) {
    1.77              SDL_OutOfMemory ();
    1.78              goto ERR_DOUBLEBUF;
    1.79 @@ -984,7 +984,7 @@
    1.80          
    1.81          while ( h-- ) {
    1.82          
    1.83 -            memcpy (dst, src, len);
    1.84 +            SDL_memcpy (dst, src, len);
    1.85              src += skip;
    1.86              dst += skip;
    1.87          }
    1.88 @@ -1211,7 +1211,7 @@
    1.89                              dockIconCacheMiss) {
    1.90  
    1.91                              numCachedDockIcons = i - firstDockIcon;
    1.92 -                            memcpy (dockIcons, &(windows[firstDockIcon]),
    1.93 +                            SDL_memcpy (dockIcons, &(windows[firstDockIcon]),
    1.94                                      numCachedDockIcons * sizeof(*windows));
    1.95                          }
    1.96  
     2.1 --- a/src/video/quartz/SDL_QuartzWM.m	Mon May 01 07:23:46 2006 +0000
     2.2 +++ b/src/video/quartz/SDL_QuartzWM.m	Mon May 01 11:07:04 2006 +0000
     2.3 @@ -41,12 +41,12 @@
     2.4      int row, bytes;
     2.5          
     2.6      /* Allocate the cursor memory */
     2.7 -    cursor = (WMcursor *)malloc(sizeof(WMcursor));
     2.8 +    cursor = (WMcursor *)SDL_malloc(sizeof(WMcursor));
     2.9      if ( cursor == NULL ) {
    2.10          SDL_OutOfMemory();
    2.11          return(NULL);
    2.12      }
    2.13 -    memset(cursor, 0, sizeof(*cursor));
    2.14 +    SDL_memset(cursor, 0, sizeof(*cursor));
    2.15      
    2.16      if (w > 16)
    2.17          w = 16;
    2.18 @@ -57,11 +57,11 @@
    2.19      bytes = (w+7)/8;
    2.20  
    2.21      for ( row=0; row<h; ++row ) {
    2.22 -        memcpy(&cursor->curs.data[row], data, bytes);
    2.23 +        SDL_memcpy(&cursor->curs.data[row], data, bytes);
    2.24          data += bytes;
    2.25      }
    2.26      for ( row=0; row<h; ++row ) {
    2.27 -        memcpy(&cursor->curs.mask[row], mask, bytes);
    2.28 +        SDL_memcpy(&cursor->curs.mask[row], mask, bytes);
    2.29          mask += bytes;
    2.30      }
    2.31      cursor->curs.hotSpot.h = hot_x;
     3.1 --- a/src/video/quartz/SDL_QuartzYUV.m	Mon May 01 07:23:46 2006 +0000
     3.2 +++ b/src/video/quartz/SDL_QuartzYUV.m	Mon May 01 11:07:04 2006 +0000
     3.3 @@ -91,16 +91,16 @@
     3.4      CDSequenceEnd (yuv_seq);
     3.5      ExitMovies();
     3.6  
     3.7 -    free (overlay->hwfuncs);
     3.8 -    free (overlay->pitches);
     3.9 -    free (overlay->pixels);
    3.10 +    SDL_free (overlay->hwfuncs);
    3.11 +    SDL_free (overlay->pitches);
    3.12 +    SDL_free (overlay->pixels);
    3.13  
    3.14      if (SDL_VideoSurface->flags & SDL_FULLSCREEN) {
    3.15          [ qz_window close ];
    3.16          qz_window = nil;
    3.17      }
    3.18  
    3.19 -    free (yuv_matrix);
    3.20 +    SDL_free (yuv_matrix);
    3.21      DisposeHandle ((Handle)yuv_idh);
    3.22  }
    3.23  
    3.24 @@ -134,7 +134,7 @@
    3.25          return NULL;
    3.26      }
    3.27  
    3.28 -    yuv_matrix = (MatrixRecordPtr) malloc (sizeof(MatrixRecord));
    3.29 +    yuv_matrix = (MatrixRecordPtr) SDL_malloc (sizeof(MatrixRecord));
    3.30      if (yuv_matrix == NULL) {
    3.31          SDL_OutOfMemory();
    3.32          return NULL;
    3.33 @@ -234,7 +234,7 @@
    3.34          return NULL;
    3.35      }
    3.36      
    3.37 -    overlay = (SDL_Overlay*) malloc (sizeof(*overlay));
    3.38 +    overlay = (SDL_Overlay*) SDL_malloc (sizeof(*overlay));
    3.39      if (overlay == NULL) {
    3.40          SDL_OutOfMemory();
    3.41          return NULL;
    3.42 @@ -267,15 +267,15 @@
    3.43              return NULL;
    3.44          }
    3.45  
    3.46 -        pixels = (Uint8**) malloc (sizeof(*pixels) * 3);
    3.47 -        pitches = (Uint16*) malloc (sizeof(*pitches) * 3);
    3.48 +        pixels = (Uint8**) SDL_malloc (sizeof(*pixels) * 3);
    3.49 +        pitches = (Uint16*) SDL_malloc (sizeof(*pitches) * 3);
    3.50          if (pixels == NULL || pitches == NULL) {
    3.51              SDL_OutOfMemory();
    3.52              return NULL;
    3.53          }
    3.54  
    3.55          yuv_pixmap = (PlanarPixmapInfoYUV420*)
    3.56 -            malloc (sizeof(PlanarPixmapInfoYUV420) +
    3.57 +            SDL_malloc (sizeof(PlanarPixmapInfoYUV420) +
    3.58                      (width * height * 2));
    3.59          if (yuv_pixmap == NULL) {
    3.60              SDL_OutOfMemory ();
    3.61 @@ -310,7 +310,7 @@
    3.62          overlay->pitches = pitches;
    3.63      }
    3.64  
    3.65 -    overlay->hwfuncs = malloc (sizeof(*overlay->hwfuncs));
    3.66 +    overlay->hwfuncs = SDL_malloc (sizeof(*overlay->hwfuncs));
    3.67      if (overlay->hwfuncs == NULL) {
    3.68          SDL_OutOfMemory();
    3.69          return NULL;