IMG_xcf.c
changeset 367 b2aa197f6774
parent 365 ce8091caddf3
child 368 8a61842d00ce
     1.1 --- a/IMG_xcf.c	Tue Apr 23 20:15:22 2013 -0700
     1.2 +++ b/IMG_xcf.c	Thu Apr 25 00:22:51 2013 -0700
     1.3 @@ -231,7 +231,7 @@
     1.4  
     1.5    tmp = SDL_ReadBE32 (src);
     1.6    if (tmp > 0) {
     1.7 -    data = (char *) malloc (sizeof (char) * tmp);
     1.8 +    data = (char *) SDL_malloc (sizeof (char) * tmp);
     1.9      SDL_RWread (src, data, tmp, 1);
    1.10    }
    1.11    else {
    1.12 @@ -261,7 +261,7 @@
    1.13    switch (prop->id) {
    1.14    case PROP_COLORMAP:
    1.15      prop->data.colormap.num = SDL_ReadBE32 (src);
    1.16 -    prop->data.colormap.cmap = (char *) malloc (sizeof (char) * prop->data.colormap.num * 3);
    1.17 +    prop->data.colormap.cmap = (char *) SDL_malloc (sizeof (char) * prop->data.colormap.num * 3);
    1.18      SDL_RWread (src, prop->data.colormap.cmap, prop->data.colormap.num*3, 1);
    1.19      break;
    1.20  
    1.21 @@ -287,16 +287,16 @@
    1.22  
    1.23  static void free_xcf_header (xcf_header * h) {
    1.24    if (h->cm_num)
    1.25 -    free (h->cm_map);
    1.26 +    SDL_free (h->cm_map);
    1.27  
    1.28 -  free (h);
    1.29 +  SDL_free (h);
    1.30  }
    1.31  
    1.32  static xcf_header * read_xcf_header (SDL_RWops * src) {
    1.33    xcf_header * h;
    1.34    xcf_prop prop;
    1.35  
    1.36 -  h = (xcf_header *) malloc (sizeof (xcf_header));
    1.37 +  h = (xcf_header *) SDL_malloc (sizeof (xcf_header));
    1.38    SDL_RWread (src, h->sign, 14, 1);
    1.39    h->width       = SDL_ReadBE32 (src);
    1.40    h->height      = SDL_ReadBE32 (src);
    1.41 @@ -318,7 +318,7 @@
    1.42        h->cm_num = prop.data.colormap.num;
    1.43        h->cm_map = (unsigned char *) SDL_malloc (sizeof (unsigned char) * 3 * h->cm_num);
    1.44        memcpy (h->cm_map, prop.data.colormap.cmap, 3*sizeof (char)*h->cm_num);
    1.45 -      free (prop.data.colormap.cmap);
    1.46 +      SDL_free (prop.data.colormap.cmap);
    1.47      }
    1.48    } while (prop.id != PROP_END);
    1.49  
    1.50 @@ -326,15 +326,15 @@
    1.51  }
    1.52  
    1.53  static void free_xcf_layer (xcf_layer * l) {
    1.54 -  free (l->name);
    1.55 -  free (l);
    1.56 +  SDL_free (l->name);
    1.57 +  SDL_free (l);
    1.58  }
    1.59  
    1.60  static xcf_layer * read_xcf_layer (SDL_RWops * src) {
    1.61    xcf_layer * l;
    1.62    xcf_prop    prop;
    1.63  
    1.64 -  l = (xcf_layer *) malloc (sizeof (xcf_layer));
    1.65 +  l = (xcf_layer *) SDL_malloc (sizeof (xcf_layer));
    1.66    l->width  = SDL_ReadBE32 (src);
    1.67    l->height = SDL_ReadBE32 (src);
    1.68    l->layer_type = SDL_ReadBE32 (src);
    1.69 @@ -358,8 +358,8 @@
    1.70  }
    1.71  
    1.72  static void free_xcf_channel (xcf_channel * c) {
    1.73 -  free (c->name);
    1.74 -  free (c);
    1.75 +  SDL_free (c->name);
    1.76 +  SDL_free (c);
    1.77  }
    1.78  
    1.79  static xcf_channel * read_xcf_channel (SDL_RWops * src) {
    1.80 @@ -401,15 +401,15 @@
    1.81  }
    1.82  
    1.83  static void free_xcf_hierarchy (xcf_hierarchy * h) {
    1.84 -  free (h->level_file_offsets);
    1.85 -  free (h);
    1.86 +  SDL_free (h->level_file_offsets);
    1.87 +  SDL_free (h);
    1.88  }
    1.89  
    1.90  static xcf_hierarchy * read_xcf_hierarchy (SDL_RWops * src) {
    1.91    xcf_hierarchy * h;
    1.92    int i;
    1.93  
    1.94 -  h = (xcf_hierarchy *) malloc (sizeof (xcf_hierarchy));
    1.95 +  h = (xcf_hierarchy *) SDL_malloc (sizeof (xcf_hierarchy));
    1.96    h->width  = SDL_ReadBE32 (src);
    1.97    h->height = SDL_ReadBE32 (src);
    1.98    h->bpp    = SDL_ReadBE32 (src);
    1.99 @@ -425,8 +425,8 @@
   1.100  }
   1.101  
   1.102  static void free_xcf_level (xcf_level * l) {
   1.103 -  free (l->tile_file_offsets);
   1.104 -  free (l);
   1.105 +  SDL_free (l->tile_file_offsets);
   1.106 +  SDL_free (l);
   1.107  }
   1.108  
   1.109  static xcf_level * read_xcf_level (SDL_RWops * src) {
   1.110 @@ -448,7 +448,7 @@
   1.111  }
   1.112  
   1.113  static void free_xcf_tile (unsigned char * t) {
   1.114 -  free (t);
   1.115 +  SDL_free (t);
   1.116  }
   1.117  
   1.118  static unsigned char * load_xcf_tile_none (SDL_RWops * src, Uint32 len, int bpp, int x, int y) {
   1.119 @@ -469,7 +469,7 @@
   1.120    t = load = (unsigned char *) SDL_malloc (len);
   1.121    reallen = SDL_RWread (src, t, 1, len);
   1.122  
   1.123 -  data = (unsigned char *) malloc (x*y*bpp);
   1.124 +  data = (unsigned char *) SDL_malloc (x*y*bpp);
   1.125    for (i = 0; i < bpp; i++) {
   1.126      d    = data + i;
   1.127      size = x*y;