pike.git / src / modules / Image / encodings / xcf.c

version» Context lines:

pike.git/src/modules/Image/encodings/xcf.c:4:   || for more information.   */      #include "global.h"   #include "image_machine.h"      #include "pike_macros.h"   #include "object.h"   #include "module_support.h"   #include "interpret.h" - #include "object.h" +    #include "svalue.h"   #include "threads.h" - #include "interpret.h" - #include "svalue.h" +    #include "mapping.h"   #include "pike_error.h"   #include "stralloc.h"   #include "builtin_functions.h"   #include "bignum.h"   #include "pike_types.h"   #include "sprintf.h"      #include "image.h"   #include "colortable.h"
pike.git/src/modules/Image/encodings/xcf.c:56:   };      struct substring   {    struct pike_string *s;    ptrdiff_t offset;    ptrdiff_t len;   };      static struct program *substring_program; + #undef SS   #define SS(X) ((struct substring*)X->storage)      static void f_substring_cast( INT32 args )   {    struct pike_string *type = sp[-args].u.string;    pop_n_elems(args); /* type have at least one more reference. */       if( type == literal_string_string )    {    struct substring *s = SS(fp->current_object);
pike.git/src/modules/Image/encodings/xcf.c:192:    ss->s = s;    s->refs++;    ss->offset = offset;    ss->len = len;    push_object( o );   }      static void free_substring(struct object *UNUSED(o))   {    if( SS(fp->current_object)->s ) -  { +     free_string( SS(fp->current_object)->s ); -  SS(fp->current_object)->s = 0; +    } - } +          typedef enum   {    PROP_END = 0,    PROP_COLORMAP = 1,    PROP_ACTIVE_LAYER = 2,    PROP_ACTIVE_CHANNEL = 3,    PROP_SELECTION = 4,    PROP_FLOATING_SELECTION = 5,
pike.git/src/modules/Image/encodings/xcf.c:515:    memset(&res, 0, sizeof(res));    res.width = read_uint( buff );    res.height = read_uint( buff );       SET_ONERROR( err, free_level, &res );    offset = read_uint( buff );    while(offset)    {    struct buffer ob = *initial;    int offset2 = read_uint( buff ); -  struct tile *tile = xalloc(sizeof(struct tile)); +  struct tile *tile = ALLOC_STRUCT(tile);    read_data( &ob, offset );    if(last_tile)    last_tile->next = tile;    last_tile = tile;    if(!res.first_tile)    res.first_tile = tile;    tile->data = ob;    tile->next = NULL;    offset = offset2;    }
pike.git/src/modules/Image/encodings/xcf.c:567:    res.width = read_uint( buff );    res.height = read_uint( buff );    res.name = read_string( buff );       SET_ONERROR( err, free_layer_mask, &res );    do    {    tmp = read_property( buff );    if(tmp.type)    { -  struct property *s = xalloc(sizeof(struct property)); +  struct property *s = ALLOC_STRUCT(property);    *s = tmp;    s->next = res.first_property;    res.first_property = s;    }    } while(tmp.type);    offset = read_uint( buff );       if(offset)    {    struct buffer ob = *initial;
pike.git/src/modules/Image/encodings/xcf.c:604:    res.width = read_uint( buff );    res.height = read_uint( buff );    res.name = read_string( buff );       SET_ONERROR( err, free_channel, &res );    do    {    tmp = read_property( buff );    if(tmp.type)    { -  struct property *s = xalloc( sizeof(struct property )); +  struct property *s = ALLOC_STRUCT(property);    *s = tmp;    s->next = res.first_property;    res.first_property = s;    }    } while( tmp.type );    offset = read_uint( buff );       if(offset)    {    struct buffer ob = *initial;
pike.git/src/modules/Image/encodings/xcf.c:643:    res.height = read_uint( buff );    res.type = xcf_read_int( buff );    res.name = read_string( buff );          do    {    tmp = read_property( buff );    if(tmp.type)    { -  struct property *s=xalloc( sizeof(struct property )); +  struct property *s=ALLOC_STRUCT(property);    *s = tmp;    s->next = res.first_property;    res.first_property = s;    }    } while( tmp.type );       h_offset = xcf_read_int( buff );    lm_offset = xcf_read_int( buff );       if(lm_offset)    {    struct buffer loffset = *initial; -  struct layer_mask *m=xalloc(sizeof(struct layer_mask)); +  struct layer_mask *m=ALLOC_STRUCT(layer_mask);    res.mask = m;    read_data( &loffset, lm_offset );    memset(m, 0, sizeof( struct layer_mask ));    *m = read_layer_mask( &loffset, initial );    }       if(h_offset)    {    struct buffer loffset = *initial;    read_data( &loffset, h_offset );
pike.git/src/modules/Image/encodings/xcf.c:711:    res.height = read_uint( data );    res.type = xcf_read_int( data );       SET_ONERROR( err, free_image, &res );       do    {    tmp = read_property( data );    if(tmp.type)    { -  struct property *s=xalloc( sizeof(struct property )); +  struct property *s=ALLOC_STRUCT(property);    *s = tmp;    s->next = res.first_property;    res.first_property = s;    }    } while( tmp.type );       while( (offset = read_uint( data )) )    {    struct buffer layer_data = initial;    struct layer tmp;    read_data( &layer_data, offset );    tmp = read_layer( &layer_data, &initial );    if( tmp.width && tmp.height )    { -  struct layer *s = xalloc( sizeof(struct layer)); +  struct layer *s = ALLOC_STRUCT(layer);    *s = tmp;    s->next = res.first_layer;    res.first_layer = s;    }    }       while( (offset = read_uint( data )) )    {    struct buffer channel_data = initial;    struct channel tmp;    read_data( &channel_data, offset );    tmp = read_channel( &channel_data, &initial );    if( tmp.width && tmp.height )    { -  struct channel *s = xalloc( sizeof(struct channel)); +  struct channel *s = ALLOC_STRUCT(channel);    *s = tmp;    s->next = res.first_channel;    res.first_channel = s;    }    }    UNSET_ONERROR( err );    return res;   }      static void push_buffer( struct buffer *b )
pike.git/src/modules/Image/encodings/xcf.c:885:    f_aggregate_mapping((INT32)(sp-osp));   }         static void image_xcf____decode( INT32 args )   {    struct pike_string *s;    struct buffer b;    struct gimp_image res;    ONERROR err; -  get_all_args( "___decode", args, "%S", &s ); +  get_all_args( NULL, args, "%S", &s );    if(args > 1)    Pike_error("Too many arguments to Image.XCF.___decode()\n");       b.s = s;    b.len = s->len;    b.str = (unsigned char *)s->str;       res = read_image( &b );    SET_ONERROR( err, free_image, &res );    push_image( &res );
pike.git/src/modules/Image/encodings/xcf.c:1179:    struct image *i=NULL, *a=NULL;    struct neo_colortable *cmap = NULL;    INT32 rxs, rys;    rgb_group *colortable=NULL;    rgb_group pix = {0,0,0};    rgb_group apix= {255,255,255}; /* avoid may use uninitialized warnings */       INT_TYPE rle, bpp, span, shrink;    unsigned int l, x=0, y=0, cx, cy;    ONERROR err; -  get_all_args( "_decode_tiles", args, "%o%O%a%i%i%O%i%d%d", +  get_all_args( NULL, args, "%o%O%a%i%i%O%i%d%d",    &io, &ao, &tiles, &rle, &bpp, &cmapo, &shrink, &rxs, &rys);          if( !(i = get_storage( io, image_program )))    Pike_error("Wrong type object argument 1 (image)\n");       if(ao && !(a = get_storage( ao, image_program )))    Pike_error("Wrong type object argument 2 (image)\n");       if( cmapo &&
pike.git/src/modules/Image/encodings/xcf.c:1288:    d.len--;    }    }    }    }    tile = od;    }       if( (size_t)(tile.len) < (size_t)(eheight * ewidth * bpp ))    { -  if( df ) free( df ); df=0; +  if( df ) {free( df ); df=0;}    continue;    }    s = (unsigned char *)tile.str;         #define LOOP_INIT() {\    int ix, iy=y/shrink; \    for(cy=0; cy<eheight; cy+=shrink,iy=((cy+y)/shrink)) \    { \    rgb_group *ip, *ap = NULL; \
pike.git/src/modules/Image/encodings/xcf.c:1496:    start_new_program();    ADD_STORAGE( struct substring );    ADD_FUNCTION("cast", f_substring_cast, tFunc(tStr,tStr), ID_PRIVATE);    ADD_FUNCTION("`[]", f_substring_index, tFunc(tInt,tInt), 0);    ADD_FUNCTION("get_short", f_substring_get_short, tFunc(tInt,tInt), 0 );    ADD_FUNCTION("get_ushort", f_substring_get_ushort, tFunc(tInt,tInt), 0 );    ADD_FUNCTION("get_int", f_substring_get_int, tFunc(tInt,tInt), 0 );    ADD_FUNCTION("get_uint", f_substring_get_uint, tFunc(tInt,tInt), 0 );    ADD_FUNCTION("_sprintf",f_substring__sprintf, tFunc(tInt tMapping,tMix), 0);    - /* set_init_callback(init_substring); */ +     set_exit_callback(free_substring);    substring_program = end_program();   }         void exit_image_xcf(void)   {   #define STRING(X) free_string(s_##X)   #include "xcf_constant_strings.h"   #undef STRING    free_program( substring_program );   }