IMG_xcf.c
changeset 415 1700d607fce3
parent 368 8a61842d00ce
child 419 e108e1228d62
     1.1 --- a/IMG_xcf.c	Sun Jul 21 11:52:59 2013 -0700
     1.2 +++ b/IMG_xcf.c	Sat Jul 27 01:18:33 2013 -0700
     1.3 @@ -288,7 +288,8 @@
     1.4  static void free_xcf_header (xcf_header * h) {
     1.5    if (h->cm_num)
     1.6      SDL_free (h->cm_map);
     1.7 -
     1.8 +  if (h->layer_file_offsets)
     1.9 +	  SDL_free (h->layer_file_offsets);
    1.10    SDL_free (h);
    1.11  }
    1.12  
    1.13 @@ -303,6 +304,7 @@
    1.14    h->image_type  = SDL_ReadBE32 (src);
    1.15  
    1.16    h->properties = NULL;
    1.17 +  h->layer_file_offsets = NULL;
    1.18    h->compr      = COMPR_NONE;
    1.19    h->cm_num = 0;
    1.20    h->cm_map = NULL;
    1.21 @@ -317,7 +319,7 @@
    1.22  
    1.23        h->cm_num = prop.data.colormap.num;
    1.24        h->cm_map = (unsigned char *) SDL_malloc (sizeof (unsigned char) * 3 * h->cm_num);
    1.25 -      memcpy (h->cm_map, prop.data.colormap.cmap, 3*sizeof (char)*h->cm_num);
    1.26 +      SDL_memcpy (h->cm_map, prop.data.colormap.cmap, 3*sizeof (char)*h->cm_num);
    1.27        SDL_free (prop.data.colormap.cmap);
    1.28      }
    1.29    } while (prop.id != PROP_END);
    1.30 @@ -417,7 +419,7 @@
    1.31    h->level_file_offsets = NULL;
    1.32    i = 0;
    1.33    do {
    1.34 -    h->level_file_offsets = (Uint32 *) realloc (h->level_file_offsets, sizeof (Uint32) * (i+1));
    1.35 +    h->level_file_offsets = (Uint32 *) SDL_realloc (h->level_file_offsets, sizeof (Uint32) * (i+1));
    1.36      h->level_file_offsets [i] = SDL_ReadBE32 (src);
    1.37    } while (h->level_file_offsets [i++]);
    1.38  
    1.39 @@ -718,11 +720,10 @@
    1.40      goto done;
    1.41    }
    1.42  
    1.43 -  head->layer_file_offsets = NULL;
    1.44    offsets = 0;
    1.45  
    1.46    while ((offset = SDL_ReadBE32 (src))) {
    1.47 -    head->layer_file_offsets = (Uint32 *) realloc (head->layer_file_offsets, sizeof (Uint32) * (offsets+1));
    1.48 +    head->layer_file_offsets = (Uint32 *) SDL_realloc (head->layer_file_offsets, sizeof (Uint32) * (offsets+1));
    1.49      head->layer_file_offsets [offsets] = (Uint32)offset;
    1.50      offsets++;
    1.51    }