/* 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 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 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 ); }
void * stringset_child_destroy( StringsetChild *ssc ) { ssc->ss->children = g_slist_remove( ssc->ss->children, ssc ); IM_FREE( ssc->label ); IM_FREE( ssc->text ); IM_FREE( ssc->tooltip ); IM_FREE( ssc ); return( NULL ); }
/* Free our state. */ static void free_state( State *state ) { int i; if( state->data ) for( i = 0; i < state->input->ysize; i++ ) IM_FREE( state->data[i] ); IM_FREE( state->data ); IM_FREE( state->buf ); }
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 ); }
/** * im_free_dmask: * @in: mask to free * * Free mask structure and any attached arrays. Return zero, so we can use * these functions as close callbacks. * * See also: im_free_dmask(). * * Returns: zero. */ int im_free_dmask( DOUBLEMASK *in ) { if( !in ) return( 0 ); IM_FREE( in->coeff ); IM_FREE( in->filename ); IM_FREE( in ); return( 0 ); }
/** * im_free_imask: * @in: mask to free * * Free mask structure and any attached arrays. Return zero, so we can use * these functions as close callbacks. * * See also: im_free_dmask(). * * Returns: zero. */ int im_free_imask( INTMASK *in ) { if( !in ) return( 0 ); IM_FREE( in->coeff ); IM_FREE( in->filename ); IM_FREE( in ); return( 0 ); }
static void managedstring_finalize( GObject *gobject ) { Managedstring *managedstring = MANAGEDSTRING( gobject ); #ifdef DEBUG printf( "managedstring_finalize: \"%s\", ", managedstring->string ); iobject_print( IOBJECT( managedstring ) ); #endif /*DEBUG*/ #ifdef DEBUG { PElement pe; PEPOINTE( &pe, &managedstring->e ); if( !PEISNOVAL( &pe ) ) managed_expanded -= 1; managed_total -= 1; } #endif /*DEBUG*/ heap_unregister_element( MANAGED( managedstring )->heap, &managedstring->e ); g_hash_table_remove( managedstring_all, managedstring ); IM_FREE( managedstring->string ); G_OBJECT_CLASS( parent_class )->finalize( gobject ); }
static void prefs_destroy( GtkObject *object ) { Prefs *prefs = PREFS( object ); #ifdef DEBUG printf( "prefs_destroy\n" ); #endif /*DEBUG*/ if( prefs->ws ) { Workspacegroup *wsg = workspace_get_workspacegroup( prefs->ws ); Filemodel *filemodel = FILEMODEL( wsg ); /* Force a recalc, in case we've changed the autorecalc * settings. Also does a scan on any widgets. */ symbol_recalculate_all_force( TRUE ); if( filemodel->modified && filemodel_top_save( filemodel, filemodel->filename ) ) filemodel_set_modified( filemodel, FALSE ); } /* My instance destroy stuff. */ FREESID( prefs->destroy_sid, prefs->ws ); IM_FREE( prefs->caption_filter ); prefs->ws = NULL; GTK_OBJECT_CLASS( parent_class )->destroy( object ); }
/* Need to implement _update_heap(), as not all model fields are directly * editable ... some are set only from expr. See also iregion.c. */ static void * iimage_update_heap( Heapmodel *heapmodel ) { Expr *expr = heapmodel->row->expr; iImage *iimage = IIMAGE( heapmodel ); ImageValue *value = &iimage->value; PElement pe; Imageinfo *ii; #ifdef DEBUG printf( "iimage_update_heap: " ); row_name_print( HEAPMODEL( iimage )->row ); printf( "\n" ); #endif /*DEBUG*/ /* Read the heap into the model, over the top of the unapplied edits. */ if( !class_get_exact( &expr->root, IOBJECT( heapmodel )->name, &pe ) ) return( FALSE ); if( !class_get_member_image( &pe, MEMBER_VALUE, &ii ) ) return( FALSE ); image_value_set( value, ii ); IM_FREE( CLASSMODEL( iimage )->filename ); if( value->ii && imageinfo_is_from_file( value->ii ) ) IM_SETSTR( CLASSMODEL( iimage )->filename, IOBJECT( value->ii )->name ); /* Classmodel _update_heap() will do _instance_new() from the fixed up * model. */ return( HEAPMODEL_CLASS( parent_class )->update_heap( heapmodel ) ); }
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 read_destroy( Read *read ) { IM_FREE( read->filename ); IM_FREEF( Mat_VarFree, read->var ); IM_FREEF( Mat_Close, read->mat ); im_free( read ); }
/* Make up a new definition. */ Symbol * workspace_add_def( Workspace *ws, const char *str ) { Column *col = workspace_column_pick( ws ); Symbol *sym; char *name; #ifdef DEBUG printf( "workspace_add_def: %s\n", str ); #endif /*DEBUG*/ if( !str || strspn( str, WHITESPACE ) == strlen( str ) ) return( NULL ); /* Try parsing as a "fred = 12" style def. */ attach_input_string( str ); if( (name = parse_test_define()) ) { sym = symbol_new( ws->sym->expr->compile, name ); IM_FREE( name ); attach_input_string( str + IM_CLIP( 0, input_state.charpos - 1, strlen( str ) ) ); } else { /* That didn't work. Make a sym from the col name. */ sym = workspace_add_symbol( ws ); attach_input_string( str ); } if( !symbol_user_init( sym ) || !parse_rhs( sym->expr, PARSE_RHS ) ) { /* Another parse error. */ expr_error_get( sym->expr ); /* Block changes to error_string ... symbol_destroy() * can set this for compound objects. */ error_block(); IDESTROY( sym ); error_unblock(); return( NULL ); } /* If we're redefining a sym, it might have a row already. */ if( !sym->expr->row ) (void) row_new( col->scol, sym, &sym->expr->root ); symbol_made( sym ); workspace_set_modified( ws, TRUE ); return( sym ); }
/* Do a image call. */ static void apply_image_call( Reduce *rc, const char *name, HeapNode **arg, PElement *out ) { Heap *heap = rc->heap; PElement rhs; char buf[FILENAME_MAX]; char filename[FILENAME_MAX]; char mode[FILENAME_MAX]; char *fn; Imageinfo *ii; /* Get string. */ PEPOINTRIGHT( arg[0], &rhs ); (void) reduce_get_string( rc, &rhs, buf, FILENAME_MAX ); /* The buf might be something like n3862.pyr.tif:1, ie. contain some * load options. Split and search just for the filename component. */ im_filename_split( buf, filename, mode ); /* Try to load image from given string. */ if( !(fn = path_find_file( filename )) ) reduce_throw( rc ); /* Reattach the mode and load. */ im_snprintf( buf, FILENAME_MAX, "%s:%s", fn, mode ); if( !(ii = imageinfo_new_input( main_imageinfogroup, NULL, heap, buf )) ) { IM_FREE( fn ); reduce_throw( rc ); } IM_FREE( fn ); PEPUTP( out, ELEMENT_MANAGED, ii ); MANAGED_UNREF( ii ); }
/* Make a new symbol, part of the current column. */ static Symbol * workspace_add_symbol( Workspace *ws ) { Column *col = workspace_column_pick( ws ); Symbol *sym; char *name; name = column_name_new( col ); sym = symbol_new( ws->sym->expr->compile, name ); IM_FREE( name ); return( sym ); }
static void workspace_finalize( GObject *gobject ) { Workspace *ws; #ifdef DEBUG printf( "workspace_finalize: %p %s\n", gobject, NN( IOBJECT( gobject )->name ) ); #endif /*DEBUG*/ g_return_if_fail( gobject != NULL ); g_return_if_fail( IS_WORKSPACE( gobject ) ); ws = WORKSPACE( gobject ); IM_FREE( ws->status ); IM_FREE( ws->local_defs ); workspace_all = g_slist_remove( workspace_all, ws ); G_OBJECT_CLASS( parent_class )->finalize( gobject ); }
/* Do "search". */ static void apply_search_call( Reduce *rc, const char *name, HeapNode **arg, PElement *out ) { char buf[MAX_STRSIZE]; PElement rhs; char *fn; /* Get string. */ PEPOINTRIGHT( arg[0], &rhs ); (void) reduce_get_string( rc, &rhs, buf, MAX_STRSIZE ); if( !(fn = path_find_file( buf )) ) /* If not found, return []. */ fn = im_strdup( NULL, "" ); if( !heap_managedstring_new( rc->heap, fn, out ) ) { IM_FREE( fn ); reduce_throw( rc ); } IM_FREE( fn ); }
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 ); }
void in_delmulti(struct in_multi * inm) { struct in_multi * p; NET netp = inm->inm_netp; int error; ENTER_CRIT_SECTION(inm); if (--inm->inm_refcount == 0) { /* Unlink from list. */ for (p = netp->mc_list; p; p = p->inm_next) { if(p == inm) /* inm is first in mc_list */ { netp->mc_list = p->inm_next; /* unlink */ break; } else if(p->inm_next == inm) /* inm is next */ { p->inm_next = inm->inm_next; /* unlink */ break; } } /* * If net has a multicast address registration routine then ask * the network driver to update its multicast reception * filter appropriately for the deleted address. */ if(netp->n_mcastlist) error = netp->n_mcastlist(inm); else error = 0; #if defined (IGMP_V2) /* * No remaining claims to this record; let IGMP know that * we are leaving the multicast group. */ if (inm->inm_addr) igmp_leavegroup(inm); #endif IM_FREE(inm); } EXIT_CRIT_SECTION(inm); }
/* Update iImage from heap. */ static gboolean iimage_class_get( Classmodel *classmodel, PElement *root ) { iImage *iimage = IIMAGE( classmodel ); ImageValue *value = &iimage->value; Imageinfo *ii; #ifdef DEBUG printf( "iimage_class_get: " ); row_name_print( HEAPMODEL( iimage )->row ); printf( "\n" ); #endif /*DEBUG*/ if( !class_get_member_image( root, MEMBER_VALUE, &ii ) ) return( FALSE ); image_value_set( value, ii ); /* Try to update the filename for this row ... get from the meta if we * can. */ IM_FREE( classmodel->filename ); if( ii ) { IMAGE *im; char *filename; if( (im = imageinfo_get( FALSE, ii )) && im_header_get_typeof( im, ORIGINAL_FILENAME ) != 0 ) { if( im_header_string( im, ORIGINAL_FILENAME, &filename ) ) return( FALSE ); } else if( imageinfo_is_from_file( ii ) ) filename = IOBJECT( ii )->name; else filename = NULL; IM_SETSTR( classmodel->filename, filename ); } return( CLASSMODEL_CLASS( parent_class )->class_get( classmodel, root ) ); }
void im_buffer_unref( im_buffer_t *buffer ) { #ifdef DEBUG printf( "** im_buffer_unref: left = %d, top = %d, " "width = %d, height = %d (%p)\n", buffer->area.left, buffer->area.top, buffer->area.width, buffer->area.height, buffer ); #endif /*DEBUG*/ g_assert( buffer->ref_count > 0 ); buffer->ref_count -= 1; if( buffer->ref_count == 0 ) { #ifdef DEBUG if( !buffer->done ) printf( "im_buffer_unref: buffer was not done\n" ); #endif /*DEBUG*/ im_buffer_undone( buffer ); buffer->im = NULL; IM_FREE( buffer->buf ); buffer->bsize = 0; im_free( buffer ); #ifdef DEBUG g_mutex_lock( im__global_lock ); g_assert( g_slist_find( im__buffers_all, buffer ) ); im__buffers_all = g_slist_remove( im__buffers_all, buffer ); printf( "%d buffers in vips\n", g_slist_length( im__buffers_all ) ); g_mutex_unlock( im__global_lock ); #endif /*DEBUG*/ } }
static int buffer_move( im_buffer_t *buffer, Rect *area ) { IMAGE *im = buffer->im; size_t new_bsize; g_assert( buffer->ref_count == 1 ); buffer->area = *area; im_buffer_undone( buffer ); g_assert( !buffer->done ); new_bsize = (size_t) IM_IMAGE_SIZEOF_PEL( im ) * area->width * area->height; if( buffer->bsize < new_bsize ) { buffer->bsize = new_bsize; IM_FREE( buffer->buf ); if( !(buffer->buf = im_malloc( NULL, buffer->bsize )) ) return( -1 ); } return( 0 ); }
void im__draw_free( Draw *draw ) { IM_FREE( draw->ink ); }
int ip_setmoptions(int optname, struct socket * so, void * val) { int error = 0; u_short i; struct ip_mreq * mreq; struct net * netp = NULL; struct ip_moptions * imo = so->inp_moptions; struct ip_moptions **imop = &so->inp_moptions; ip_addr addr; if (imo == NULL) { /* * No multicast option buffer attached to the pcb; * allocate one and initialize to default values. */ imo = (struct ip_moptions*)IM_ALLOC(sizeof(*imo)); if (imo == NULL) return (ENOBUFS); *imop = imo; imo->imo_multicast_netp = NULL; imo->imo_multicast_ttl = IP_DEFAULT_MULTICAST_TTL; imo->imo_multicast_loop = IP_DEFAULT_MULTICAST_LOOP; imo->imo_num_memberships = 0; } switch (optname) { case IP_MULTICAST_IF: /* * Select the interface for outgoing multicast packets. */ addr = *(ip_addr *)val; /* * AADDR is used to remove a previous selection. * When no interface is selected, a default one is * chosen every time a multicast packet is sent. */ if (addr == AADDR) { imo->imo_multicast_netp = NULL; break; } /* * The selected interface is identified by its local * IP address. Find the interface and confirm that * it supports multicasting. */ IPADDR_TO_NETP(addr, &netp); if ((netp == NULL) || (netp->n_mcastlist) == NULL) { error = EADDRNOTAVAIL; break; } if (addr != AADDR) imo->imo_multicast_netp = netp; break; case IP_MULTICAST_TTL: /* * Set the IP time-to-live for outgoing multicast packets. */ imo->imo_multicast_ttl = *(u_char *)val; break; case IP_MULTICAST_LOOP: /* * Set the loopback flag for outgoing multicast packets. * Must be zero or one. */ if (*(u_char *)val > 1) { error = EINVAL; break; } imo->imo_multicast_loop = *(u_char *)(val); break; case IP_ADD_MEMBERSHIP: /* * Add a multicast group membership. * Group must be a valid IP multicast address. */ mreq = (struct ip_mreq *)val; if (!IN_MULTICAST(ntohl(mreq->imr_multiaddr))) { error = EINVAL; break; } /* * If no interface address was provided, use the interface of * the route to the given multicast address. * For the Iniche stack implementation, look for a default * interface that supports multicast. */ IPADDR_TO_NETP(mreq->imr_interface, &netp); /* * See if we found an interface, and confirm that it * supports multicast. */ if (netp == NULL || (netp->n_mcastlist) == NULL) { error = EADDRNOTAVAIL; break; } /* * See if the membership already exists or if all the * membership slots are full. */ for (i = 0; i < imo->imo_num_memberships; ++i) { if (imo->imo_membership[i]->inm_netp == netp && imo->imo_membership[i]->inm_addr == mreq->imr_multiaddr) { break; } } if (i < imo->imo_num_memberships) { error = EADDRINUSE; break; } if (i == IP_MAX_MEMBERSHIPS) { error = ETOOMANYREFS; break; } /* * Everything looks good; add a new record to the multicast * address list for the given interface. */ if ((imo->imo_membership[i] = in_addmulti(&mreq->imr_multiaddr, netp, 4)) == NULL) { error = ENOBUFS; break; } ++imo->imo_num_memberships; break; case IP_DROP_MEMBERSHIP: /* * Drop a multicast group membership. * Group must be a valid IP multicast address. */ mreq = (struct ip_mreq *)val; if (!IN_MULTICAST(ntohl(mreq->imr_multiaddr))) { error = EINVAL; break; } /* * If an interface address was specified, get a pointer * to its ifnet structure. If an interface address was not * specified, get a pointer to the first interface that * supports multicast. */ IPADDR_TO_NETP(mreq->imr_interface, &netp); if (netp == NULL) { error = EADDRNOTAVAIL; break; } /* * Find the membership in the membership array. */ for (i = 0; i < imo->imo_num_memberships; ++i) { if ((netp == NULL || imo->imo_membership[i]->inm_netp == netp) && imo->imo_membership[i]->inm_addr == mreq->imr_multiaddr) { break; } } if (i == imo->imo_num_memberships) { error = EADDRNOTAVAIL; break; } /* * Give up the multicast address record to which the * membership points. */ in_delmulti(imo->imo_membership[i]); /* * Remove the gap in the membership array. */ for (++i; i < imo->imo_num_memberships; ++i) imo->imo_membership[i-1] = imo->imo_membership[i]; --imo->imo_num_memberships; break; default: error = EOPNOTSUPP; break; } /* * If all options have default values, no need to keep the mbuf. */ if (imo->imo_multicast_netp == NULL && imo->imo_multicast_ttl == IP_DEFAULT_MULTICAST_TTL && imo->imo_multicast_loop == IP_DEFAULT_MULTICAST_LOOP && imo->imo_num_memberships == 0) { IM_FREE(*imop); *imop = NULL; } return (error); }