/* Free any resources we have. */ static void im_region_reset( REGION *reg ) { IM_FREEF( im_window_unref, reg->window ); IM_FREEF( im_buffer_unref, reg->buffer ); reg->invalid = FALSE; }
static void read_destroy( Read *read ) { IM_FREE( read->filename ); IM_FREEF( Mat_VarFree, read->var ); IM_FREEF( Mat_Close, read->mat ); im_free( read ); }
static void write_destroy( Write *write ) { jpeg_destroy_compress( &write->cinfo ); IM_FREEF( im_close, write->in ); IM_FREEF( fclose, write->eman.fp ); IM_FREE( write->row_pointer ); IM_FREE( write->profile_bytes ); IM_FREEF( im_close, write->inverted ); im_free( write ); }
/* Free a Histogram. */ static void hist_free( Histogram *hist ) { IM_FREE( hist->bins ); IM_FREEF( im_region_free, hist->vreg ); IM_FREE( hist ); }
static void workspaceview_layout_loop( WorkspaceLayout *layout ) { layout->cview = NULL; layout->area.left = INT_MAX; slist_map( layout->undone_columns, (SListMapFn) workspaceview_layout_find_leftmost, layout ); layout->current_columns = NULL; layout->area.width = GTK_WIDGET( layout->cview )->allocation.width; slist_map( layout->undone_columns, (SListMapFn) workspaceview_layout_find_similar_x, layout ); layout->current_columns = g_slist_sort( layout->current_columns, (GCompareFunc) workspaceview_layout_sort_y ); layout->out_y = workspaceview_layout_top; slist_map( layout->current_columns, (SListMapFn) workspaceview_layout_set_pos, layout ); layout->out_x += layout->area.width + workspaceview_layout_hspacing; slist_map( layout->current_columns, (SListMapFn) workspaceview_layout_strike, layout ); IM_FREEF( g_slist_free, layout->current_columns ); }
static int junk_node( JoinNode *node ) { IM_FREEF( g_slist_free, node->overlaps ); return( 0 ); }
static int affine_free( Affine *affine ) { IM_FREEF( g_object_unref, affine->interpolate ); return( 0 ); }
static int morph_close( Morph *morph ) { IM_FREEF( im_free_imask, morph->mask ); pass_free( morph ); return( 0 ); }
static int read_destroy( Read *read ) { #ifdef DEBUG printf( "im_magick2vips: read_destroy: %s\n", read->filename ); #endif /*DEBUG*/ IM_FREEF( DestroyImage, read->image ); IM_FREEF( DestroyImageInfo, read->image_info ); IM_FREE( read->frames ); IM_FREE( read->filename ); DestroyExceptionInfo( &read->exception ); IM_FREEF( g_mutex_free, read->lock ); im_free( read ); return( 0 ); }
static void pass_free( Morph *morph ) { int i; for( i = 0; i < morph->n_pass; i++ ) IM_FREEF( vips_vector_free, morph->pass[i].vector ); morph->n_pass = 0; }
/* Free a sequence value. */ static int aconv_stop( void *vseq, void *a, void *b ) { AConvSequence *seq = (AConvSequence *) vseq; IM_FREEF( im_region_free, seq->ir ); return( 0 ); }
/* Free a sequence value. */ static int shrink_stop( void *vseq, void *a, void *b ) { SeqInfo *seq = (SeqInfo *) vseq; IM_FREEF( im_region_free, seq->ir ); return( 0 ); }
static gboolean workspace_load( Model *model, ModelLoadState *state, Model *parent, xmlNode *xnode ) { Workspace *ws = WORKSPACE( model ); char buf[FILENAME_MAX]; char *txt; g_assert( IS_WORKSPACEGROUP( parent ) ); /* "view" is optional, for backwards compatibility. */ if( get_sprop( xnode, "view", buf, FILENAME_MAX ) ) { WorkspaceMode mode = char_to_workspacemode( buf ); if( (int) mode >= 0 ) /* Could call workspace_set_mode(), but this is only a * load, so so what. */ ws->mode = mode; } /* Also optional. */ (void) get_dprop( xnode, "scale", &ws->scale ); (void) get_dprop( xnode, "offset", &ws->offset ); (void) get_bprop( xnode, "locked", &ws->locked ); (void) get_bprop( xnode, "lpane_open", &ws->lpane_open ); (void) get_iprop( xnode, "lpane_position", &ws->lpane_position ); (void) get_bprop( xnode, "rpane_open", &ws->rpane_open ); (void) get_iprop( xnode, "rpane_position", &ws->rpane_position ); if( get_sprop( xnode, "name", buf, FILENAME_MAX ) ) { IM_SETSTR( IOBJECT( ws )->name, buf ); } if( get_sprop( xnode, "caption", buf, FILENAME_MAX ) ) { IM_SETSTR( IOBJECT( ws )->caption, buf ); } /* Don't use get_sprop() and avoid a limit on def size. */ if( (txt = (char *) xmlGetProp( xnode, (xmlChar *) "local_defs" )) ) { (void) workspace_local_set( ws, txt ); IM_FREEF( xmlFree, txt ); } (void) get_iprop( xnode, "major", &ws->compat_major ); (void) get_iprop( xnode, "minor", &ws->compat_minor ); if( !MODEL_CLASS( parent_class )->load( model, state, parent, xnode ) ) return( FALSE ); return( TRUE ); }
/** * im_region_buffer: * @reg: region to operate upon * @r: #Rect of pixels you need to be able to address * * The region is transformed so that at least @r pixels are available as a * memory buffer. * * Returns: 0 on success, or -1 for error. */ int im_region_buffer( REGION *reg, Rect *r ) { IMAGE *im = reg->im; Rect image; Rect clipped; im__region_check_ownership( reg ); /* Clip against image. */ image.top = 0; image.left = 0; image.width = im->Xsize; image.height = im->Ysize; im_rect_intersectrect( r, &image, &clipped ); /* Test for empty. */ if( im_rect_isempty( &clipped ) ) { im_error( "im_region_buffer", "%s", _( "valid clipped to nothing" ) ); return( -1 ); } /* Have we been asked to drop caches? We want to throw everything * away. * * If not, try to reuse the current buffer. */ if( reg->invalid ) { im_region_reset( reg ); if( !(reg->buffer = im_buffer_new( im, &clipped )) ) return( -1 ); } else { /* Don't call im_region_reset() ... we combine buffer unref * and new buffer ref in one call to reduce malloc/free * cycling. */ IM_FREEF( im_window_unref, reg->window ); if( !(reg->buffer = im_buffer_unref_ref( reg->buffer, im, &clipped )) ) return( -1 ); } /* Init new stuff. */ reg->valid = reg->buffer->area; reg->bpl = IM_IMAGE_SIZEOF_PEL( im ) * reg->buffer->area.width; reg->type = IM_REGION_BUFFER; reg->data = reg->buffer->buf; return( 0 ); }
static int junk_table( SymbolTable *st ) { int i; for( i = 0; i < st->sz; i++ ) IM_FREEF( g_slist_free, st->table[i] ); return( 0 ); }
/* Free a sequence value. */ static int morph_stop( void *vseq, void *a, void *b ) { MorphSequence *seq = (MorphSequence *) vseq; IM_FREEF( im_region_free, seq->ir ); IM_FREE( seq->t1 ); IM_FREE( seq->t2 ); return( 0 ); }
static void read_destroy( Read *read ) { IM_FREE( read->name ); IM_FREEF( fclose, read->fp ); if( read->pPng ) png_destroy_read_struct( &read->pPng, &read->pInfo, NULL ); IM_FREE( read->row_pointer ); IM_FREE( read->data ); im_free( read ); }
/* Unref old, ref new, in a single operation. Reuse stuff if we can. The * buffer we return might or might not be done. */ im_buffer_t * im_buffer_unref_ref( im_buffer_t *old_buffer, IMAGE *im, Rect *area ) { im_buffer_t *buffer; g_assert( !old_buffer || old_buffer->im == im ); /* Is the current buffer OK? */ if( old_buffer && im_rect_includesrect( &old_buffer->area, area ) ) return( old_buffer ); /* Does the new area already have a buffer? */ if( (buffer = buffer_find( im, area )) ) { IM_FREEF( im_buffer_unref, old_buffer ); return( buffer ); } /* Is the current buffer unshared? We can just move it. */ if( old_buffer && old_buffer->ref_count == 1 ) { if( buffer_move( old_buffer, area ) ) { im_buffer_unref( old_buffer ); return( NULL ); } return( old_buffer ); } /* Fallback ... unref the old one, make a new one. */ IM_FREEF( im_buffer_unref, old_buffer ); if( !(buffer = im_buffer_new( im, area )) ) return( NULL ); return( buffer ); }
static void read_destroy( Read *read ) { IM_FREEF( g_mutex_free, read->lock ); while( read->cache ) { Tile *tile = (Tile *) read->cache->data; tile_destroy( tile ); } im_free( read ); }
static void buffer_cache_free( im_buffer_cache_t *cache ) { #ifdef DEBUG_CREATE buffer_cache_n -= 1; printf( "buffer_cache_free: freeing cache %p on thread %p\n", cache, g_thread_self() ); printf( "\t(%d cachees left)\n", buffer_cache_n ); #endif /*DEBUG_CREATE*/ IM_FREEF( g_hash_table_destroy, cache->hash ); IM_FREE( cache ); }
static void tile_destroy( Tile *tile ) { Read *read = tile->read; read->cache = g_slist_remove( read->cache, tile ); read->ntiles -= 1; g_assert( read->ntiles >= 0 ); tile->read = NULL; IM_FREEF( im_region_free, tile->region ); im_free( tile ); }
static void icontainer_finalize( GObject *gobject ) { iContainer *icontainer; g_return_if_fail( gobject != NULL ); g_return_if_fail( IS_ICONTAINER( gobject ) ); icontainer = ICONTAINER( gobject ); IM_FREEF( g_hash_table_destroy, icontainer->child_hash ); G_OBJECT_CLASS( parent_class )->finalize( gobject ); }
/* Destroy a sequence value. */ static int maplut_stop( void *vseq, void *a, void *b ) { Seq *seq = (Seq *) vseq; LutInfo *st = (LutInfo *) b; /* Add to global stats. */ st->overflow += seq->overflow; IM_FREEF( im_region_free, seq->ir ); return( 0 ); }
/* Region should be a pixel buffer. On return, check * reg->buffer->done to see if there are pixels there already. Otherwise, you * need to calculate. */ int im_region_buffer( REGION *reg, Rect *r ) { IMAGE *im = reg->im; Rect image; Rect clipped; im__region_check_ownership( reg ); /* Clip against image. */ image.top = 0; image.left = 0; image.width = im->Xsize; image.height = im->Ysize; im_rect_intersectrect( r, &image, &clipped ); /* Test for empty. */ if( im_rect_isempty( &clipped ) ) { im_error( "im_region_buffer", _( "valid clipped to nothing" ) ); return( -1 ); } /* Already have stuff? */ if( reg->type == IM_REGION_BUFFER && im_rect_includesrect( ®->valid, &clipped ) && reg->buffer && !reg->buffer->invalid ) return( 0 ); /* Don't call im_region_reset() ... we combine buffer unref and new * buffer ref in one call to reduce malloc/free cycling. */ IM_FREEF( im_window_unref, reg->window ); if( !(reg->buffer = im_buffer_unref_ref( reg->buffer, im, &clipped )) ) return( -1 ); /* Init new stuff. */ reg->valid = reg->buffer->area; reg->bpl = IM_IMAGE_SIZEOF_PEL( im ) * reg->buffer->area.width; reg->type = IM_REGION_BUFFER; reg->data = reg->buffer->buf; return( 0 ); }
/* Free a sequence value. */ static int conv_stop( void *vseq, void *a, void *b ) { ConvSequence *seq = (ConvSequence *) vseq; Conv *conv = (Conv *) b; /* Add local under/over counts to global counts. */ conv->overflow += seq->overflow; conv->underflow += seq->underflow; IM_FREEF( im_region_free, seq->ir ); return( 0 ); }
static Read * read_new( const char *filename, IMAGE *out ) { Read *read; if( !(read = IM_NEW( NULL, Read )) ) return( NULL ); read->filename = im_strdup( NULL, filename ); read->out = out; read->mat = NULL; read->var = NULL; if( !(read->mat = Mat_Open( filename, MAT_ACC_RDONLY )) ) { im_error( "im_mat2vips", _( "unable to open \"%s\"" ), filename ); read_destroy( read ); return( NULL ); } for(;;) { if( !(read->var = Mat_VarReadNextInfo( read->mat )) ) { im_error( "im_mat2vips", _( "no matrix variables in \"%s\"" ), filename ); read_destroy( read ); return( NULL ); } #ifdef DEBUG printf( "im_mat2vips: seen:\n" ); printf( "var->name == %s\n", read->var->name ); printf( "var->class_type == %d\n", read->var->class_type ); printf( "var->rank == %d\n", read->var->rank ); #endif /*DEBUG*/ /* Vector to colour image is OK for us. */ if( read->var->rank >= 1 && read->var->rank <= 3 ) break; IM_FREEF( Mat_VarFree, read->var ); } return( read ); }
static void column_finalize( GObject *gobject ) { Column *col; #ifdef DEBUG printf( "column_finalize\n" ); #endif /*DEBUG*/ g_return_if_fail( gobject != NULL ); g_return_if_fail( IS_COLUMN( gobject ) ); col = COLUMN( gobject ); if( col == column_last_new ) column_last_new = NULL; IM_FREEF( g_source_remove, col->scrollto_timeout ); G_OBJECT_CLASS( parent_class )->finalize( gobject ); }
static void iimage_finalize( GObject *gobject ) { iImage *iimage; #ifdef DEBUG printf( "iimage_finalize\n" ); #endif /*DEBUG*/ g_return_if_fail( gobject != NULL ); g_return_if_fail( IS_IIMAGE( gobject ) ); iimage = IIMAGE( gobject ); image_value_destroy( &iimage->value ); IM_FREEF( g_slist_free, iimage->views ); vips_buf_destroy( &iimage->caption_buffer ); G_OBJECT_CLASS( parent_class )->finalize( gobject ); }
static void workspaceview_destroy( GtkObject *object ) { Workspaceview *wview; #ifdef DEBUG printf( "workspaceview_destroy: %p\n", object ); #endif /*DEBUG*/ g_return_if_fail( object != NULL ); g_return_if_fail( IS_WORKSPACEVIEW( object ) ); wview = WORKSPACEVIEW( object ); /* Instance destroy. */ workspaceview_scroll_stop( wview ); IM_FREEF( iwindow_cursor_context_destroy, wview->context ); FREESID( wview->watch_changed_sid, main_watchgroup ); DESTROY_GTK( wview->popup ); GTK_OBJECT_CLASS( parent_class )->destroy( object ); }
/* Stop the tally_scroll timer. */ static void workspaceview_scroll_stop( Workspaceview *wview ) { IM_FREEF( g_source_remove, wview->timer ); }