int storePoly (struct Plex *plex) { char message[MAXLINE]; if (!storePolyBefore(plex)) return (0); if (plex -> dimension == 2) { if (!cutPoly2(plex)) return (0); } else if (plex -> dimension == 3) { if (!cutPoly3(plex)) return (0); } if (!storePolyAfter(plex)) return (0); free_objects (PLEXEDGE, (short *) (plex -> plexedges)); plex -> plexedges = NULL; if (plex -> plextriangles != NULL) { free_objects (PLEXTRIANGLE, (short *) (plex -> plextriangles)); plex -> plextriangles = NULL; } if (plex -> dimension == 3) { sprintf (message, "%8ld edges after dicing", plex -> n_edge); inform (message); sprintf (message, "%8ld triangles after dicing", plex -> n_triangle); inform (message); } return (1); }
void rt_deletescene(SceneHandle voidscene) { scenedef * scene = (scenedef *) voidscene; list * cur, * next; if (scene != NULL) { if (scene->imginternal) { free(scene->img); } /* tear down and deallocate persistent rendering threads */ destroy_render_threads(scene); /* tear down and deallocate persistent scanline receives */ if (scene->parbuf != NULL) rt_delete_scanlinereceives(scene->parbuf); /* free all lights */ cur = scene->lightlist; while (cur != NULL) { next = cur->next; /* free lights that have special data, or aren't freed */ /* as part of the object list deallocation loop. */ free_light_special(cur->item); free(cur); cur = next; } /* free all textures */ cur = scene->texlist; while (cur != NULL) { next = cur->next; ((texture *) cur->item)->methods->freetex(cur->item); /* free texture */ free(cur); /* free list entry */ cur = next; } /* free all clipping planes */ cur = scene->cliplist; while (cur != NULL) { next = cur->next; free(((clip_group *) cur->item)->planes); /* free array of clip planes */ free(cur->item); /* free clip group struct */ free(cur); /* free list entry */ cur = next; } /* free all other textures, MIP Maps, and images */ FreeTextures(); free(scene->cpuinfo); free_objects(scene->objgroup.boundedobj); free_objects(scene->objgroup.unboundedobj); free(scene); } }
void reset_object(void) { if (rootobj != NULL) free_objects(rootobj); rootobj = NULL; numobjects = 0; /* set number of objects back to 0 */ }
// Create a new Output Port and saves the Ruby Callback proc. static VALUE t_create_output_port(VALUE self, VALUE client_instance, VALUE port_name) { MIDIPortRef out_port; RbMIDIClient* client; Data_Get_Struct(client_instance, RbMIDIClient, client); CFStringRef port_str = CFStringCreateWithCString(kCFAllocatorDefault, RSTRING(port_name)->ptr, kCFStringEncodingASCII); MIDIOutputPortCreate(client->client, port_str, &out_port); CFRelease(port_str); VALUE outputport_instance = rb_class_new_instance(0, 0, cOutputPort); if( outputport_instance == Qnil ) { free_objects(); rb_fatal("Couldn't create an instance of OutputPort!"); } RbOutputPort* port_struct; Data_Get_Struct(outputport_instance, RbOutputPort, port_struct); port_struct->output_port = out_port; return outputport_instance; }
// Create a new destination endpoint static VALUE t_create_destination(VALUE self, VALUE client_instance, VALUE destination_name) { MIDIEndpointRef destination; RbMIDIClient* client; Data_Get_Struct(client_instance, RbMIDIClient, client); CFStringRef destination_str = CFStringCreateWithCString(kCFAllocatorDefault, RSTRING(destination_name)->ptr, kCFStringEncodingASCII); MIDIDestinationCreate(client->client, destination_str, RbMIDIReadProc, NULL, &destination); VALUE destination_instance = rb_class_new_instance(0, 0, cEndpoint); if( destination_instance == Qnil ) { free_objects(); rb_fatal("Couldn't create an instance of Endpoint!"); } RbEndpoint* endpoint_struct; Data_Get_Struct(destination_instance, RbEndpoint, endpoint_struct); endpoint_struct->endpoint = destination; return destination_instance; }
// Create a new source endpoint static VALUE t_create_source(VALUE self, VALUE client_instance, VALUE source_name) { MIDIEndpointRef source; RbMIDIClient* client; Data_Get_Struct(client_instance, RbMIDIClient, client); CFStringRef source_str = CFStringCreateWithCString(kCFAllocatorDefault, RSTRING(source_name)->ptr, kCFStringEncodingASCII); MIDISourceCreate(client->client, source_str, &source); VALUE source_instance = rb_class_new_instance(0, 0, cEndpoint); if( source_instance == Qnil ) { free_objects(); rb_fatal("Couldn't create an instance of Endpoint!"); } RbEndpoint* endpoint_struct; Data_Get_Struct(source_instance, RbEndpoint, endpoint_struct); endpoint_struct->endpoint = source; return source_instance; }
static void free_bndbox(void * v) { bndbox * b = (bndbox *) v; free_objects(b->objlist); free(b); }
// Create a new Input Port and saves the Ruby Callback proc. static VALUE t_create_input_port(VALUE self, VALUE client_instance, VALUE port_name) { MIDIPortRef in_port; RbMIDIClient* client; Data_Get_Struct(client_instance, RbMIDIClient, client); CFStringRef port_str = CFStringCreateWithCString(kCFAllocatorDefault, RSTRING(port_name)->as.heap.ptr, kCFStringEncodingASCII); MIDIInputPortCreate(client->client, port_str, RbMIDIReadProc, NULL, &in_port); CFRelease(port_str); VALUE inputport_instance = rb_class_new_instance(0, 0, cInputPort); if( inputport_instance == Qnil ) { free_objects(); rb_fatal("Couldn't create an instance of InputPort!"); } RbInputPort* port_struct; Data_Get_Struct(inputport_instance, RbInputPort, port_struct); port_struct->input_port = in_port; return inputport_instance; }
void free_pairs (struct surface *this_srf) { if (this_srf -> n_pair > 0 && this_srf -> pair_array != NULL) { free_objects (PAIR, (short *) (this_srf -> pair_array)); this_srf -> pair_array = NULL; this_srf -> n_pair = 0; } }
static void init_midi_data() { midi_data = CFArrayCreateMutable(kCFAllocatorDefault, 0, NULL); if( midi_data == NULL ) { free_objects(); rb_sys_fail("Failed to allocate CFMutableArray"); } }
static void install_at_exit_handler() { // Poor Ruby programmers destructor if( atexit(free_objects) != 0 ) { free_objects(); rb_sys_fail("Failed to register atexit function"); } }
/****************************************************************************** * Name main * * This utility, as currently written, repacks objects in the trash directory * due to mismatches between the chunk count specified in the trash file xattr * and the actual number of files found in trash for the specified packed * object. * * The method for determining whether objects need to repacked is to read the * the file specied by the -d option. This is typically the * tmp_packed_log file from garbage collection. This file lists the packed * object name and associated files for the packed object. It only lists those * objects that could NOT reconcile with the file counts. The format of this * file is: * * OBJECT_NAME FILE_NAME EXPECTED_FILE_COUNT HOST BUCKED OBJID * * This utility reads the file and finds all files for the associated object * The number of files found will be less than EXPECTED_FILE_COUNT (post xattr * chunk count). It then proceeds to read in the file objects and rewrite * them back to a new object with offsets re-defined. Xattrs are updated * to reflect the new object, chunk_count, and offsets * ******************************************************************************/ int main(int argc, char **argv){ int c; char *fnameP = NULL; char *outfile = NULL; //char *ns = NULL; while ((c=getopt(argc,argv,"d:o:h")) != EOF) { switch(c) { case 'd': fnameP = optarg; break; //case 'n': ns = optarg; break; case 'o': outfile = optarg; break; case 'h': print_usage(); default: exit(-1); } } if (fnameP == NULL || outfile == NULL) { print_usage(); exit(-1); } if ( setup_config() == -1 ) { fprintf(stderr,"Error: Initializing Configs and Aws failed, quitting!!\n"); exit(-1); } File_Handles file_info; File_Handles *file_status = &file_info; // open associated log file and packed log file if ((file_status->outfd = fopen(outfile,"w")) == NULL){ fprintf(stderr, "Failed to open %s\n", outfile); exit(1); } strcpy(file_status->packed_log, fnameP); //MarFS_Namespace* namespace; //namespace = find_namespace_by_name(ns); //MarFS_Repo* repo = namespace->iwrite_repo; // Find the correct repo - the one with the largest range //MarFS_Repo* repo = find_repo_by_range(namespace, (size_t)-1); repack_objects *objs = NULL; find_repack_objects(file_status, &objs); pack_objects(file_status, objs); update_meta(file_status, objs); free_objects(objs); return 0; }
/* extract a large number of untypeds from the allocator */ static unsigned int populate_untypeds(vka_object_t *untypeds) { /* First reserve some memory for the driver */ vka_object_t reserve[DRIVER_NUM_UNTYPEDS]; unsigned int reserve_num = allocate_untypeds(reserve, DRIVER_UNTYPED_MEMORY, DRIVER_NUM_UNTYPEDS); /* Now allocate everything else for the tests */ unsigned int num_untypeds = allocate_untypeds(untypeds, UINT_MAX, ARRAY_SIZE(untyped_size_bits_list)); /* Fill out the size_bits list */ for (unsigned int i = 0; i < num_untypeds; i++) { untyped_size_bits_list[i] = untypeds[i].size_bits; } /* Return reserve memory */ free_objects(reserve, reserve_num); /* Return number of untypeds for tests */ assert(num_untypeds > 0); return num_untypeds; }
static VALUE t_create_client(VALUE self, VALUE client_name) { VALUE midiclient_instance = rb_class_new_instance(0, 0, cMIDIClient); if( midiclient_instance == Qnil ) { free_objects(); rb_fatal("Couldn't create an instance of MIDIClient!"); } MIDIClientRef midi_client; CFStringRef client_str = CFStringCreateWithCString(kCFAllocatorDefault, RSTRING(client_name)->as.heap.ptr, kCFStringEncodingASCII); MIDIClientCreate(client_str, NULL, NULL, &midi_client); CFRelease(client_str); RbMIDIClient* client_struct; Data_Get_Struct(midiclient_instance, RbMIDIClient, client_struct); client_struct->client = midi_client; return midiclient_instance; }
static void grid_free(void * v) { int i, numvoxels; grid * g = (grid *) v; /* loop through all voxels and free the object lists */ numvoxels = g->xsize * g->ysize * g->zsize; for (i=0; i<numvoxels; i++) { objectlist * lcur, * lnext; lcur = g->cells[i]; while (lcur != NULL) { lnext = lcur->next; free(lcur); } } /* free the grid cells */ free(g->cells); /* free all objects on the grid object list */ free_objects(g->objects); free(g); }
struct surface *density_to_polyhedron (struct surface *den, double ctrlev, double sphere_radius, int smooth) { int j, k; long i, dimension; long vn0, vn1, vn2, en0, en1, en2, uen0, uen1, uen2; long dimensions[3], origin[3], width[3], limit[3]; long n_vertex, n_edge, n_triangle; long *dedg, *dtri; float *densities, *dvtx, *dnml; double bounds[2][3]; double cube_width; struct phnvtx *vtx; struct phnedg *edg; struct phntri *tri; char message[128]; struct msdata *msd; struct surface *phn; struct vanity *vanities; vanities = NULL; cube_width = den -> cube_width; for (j = 0; j < 3; j++) { origin[j] = den -> origin[j]; width[j] = den -> width[j]; limit[j] = den -> limit[j]; } densities = den -> densities; for (k = 0; k < 3; k++) { bounds[0][k] = origin[k] * cube_width; bounds[1][k] = limit[k] * cube_width; dimensions[k] = width[k]; } dimension = 3; vanities = smooth_density (dimension, dimensions, densities, (float) sphere_radius, (float) cube_width, smooth); msd = doXelp (dimension, dimensions, bounds, ctrlev, vanities); if (msd == NULL) { set_error1 ("density_to_polyhedron: doXelp returns null"); return (NULL); } if (msd -> narray != 4) { set_error1 ("density_to_polyhedron: doXelp returns wrong number of arrays"); return (NULL); } /* store msd data into polyhedron */ n_vertex = msd -> counts[1]; n_edge = msd -> counts[2]; n_triangle = msd -> counts[3]; if (n_vertex <= 0) { set_error1 ("(density_to_polyhedron): bad n_vertex"); return (NULL); } if (n_edge <= 0) { set_error1 ("(density_to_polyhedron): bad n_edge"); return (NULL); } if (n_triangle <= 0) { set_error1 ("(density_to_polyhedron): bad n_triangle"); return (NULL); } phn = init_phn (n_vertex, n_edge, n_triangle); if (phn == NULL) { set_error1 ("density_to_polyhedron: no memory for polyhedron"); return (NULL); } /* skip over plexlines */ phn -> format = 1; /* initialize bounds */ for (k = 0; k < 3; k++) { phn -> bounds[0][k] = 1000000.0; phn -> bounds[1][k] = -1000000.0; } phn -> minvals[0] = ctrlev; phn -> maxvals[0] = ctrlev; for (i = 0; i < phn -> n_phnvtx; i++) { dvtx = msd -> floats[1] + 6 * i; dnml = dvtx + 3; vtx = *(phn -> phnvtx_handles + i); for (k = 0; k < 3; k++) { vtx -> center[k] = *(dvtx+k); vtx -> outward[k] = *(dnml+k); } normalize (vtx -> outward); for (k = 0; k < 3; k++) { if (vtx -> center[k] < phn -> bounds[0][k]) phn -> bounds[0][k] = vtx -> center[k]; if (vtx -> center[k] > phn -> bounds[1][k]) phn -> bounds[1][k] = vtx -> center[k]; } } for (k = 0; k < 3; k++) phn -> center[k] = (phn -> bounds[0][k] + phn -> bounds[1][k]) / 2.0; for (i = 0; i < phn -> n_phnedg; i++) { dedg = msd -> longs[2] + 2 * i; edg = *(phn -> phnedg_handles + i); vn0 = *dedg; vn1 = *(dedg+1); if (vn0 < 1 || vn0 > phn -> n_phnvtx) { sprintf (message, "(density_to_polyhedron): bad vertex number: %6ld", vn0); set_error1(message); return (NULL); } if (vn1 < 1 || vn1 > phn -> n_phnvtx) { sprintf (message, "(density_to_polyhedron): bad vertex number: %6ld", vn1); set_error1(message); return (NULL); } edg -> vtxnum[0] = vn0; edg -> vtxnum[1] = vn1; } for (i = 0; i < phn -> n_phntri; i++) { tri = *(phn -> phntri_handles + i); dtri = msd -> longs[3] + 6 * i; en0 = *dtri; en1 = *(dtri+1); en2 = *(dtri+2); vn0 = *(dtri+3); vn1 = *(dtri+4); vn2 = *(dtri+5); uen0 = abs (en0); uen1 = abs (en1); uen2 = abs (en2); if (uen0 < 1 || uen0 > phn -> n_phnedg) { set_error1 ("(density_to_polyhedron): bad edge number"); return (NULL); } if (uen1 < 1 || uen1 > phn -> n_phnedg) { set_error1 ("(density_to_polyhedron): bad edge number"); return (NULL); } if (uen2 < 1 || uen2 > phn -> n_phnedg) { set_error1 ("(density_to_polyhedron): bad edge number"); return (NULL); } if (vn0 < 1 || vn0 > phn -> n_phnvtx) { sprintf (message, "(density_to_polyhedron): bad vertex number: %6ld", vn0); set_error1(message); return (NULL); } if (vn1 < 1 || vn1 > phn -> n_phnvtx) { sprintf (message, "(density_to_polyhedron): bad vertex number: %6ld", vn1); set_error1(message); return (NULL); } if (vn2 < 1 || vn2 > phn -> n_phnvtx) { sprintf (message, "(density_to_polyhedron): bad vertex number: %6ld", vn2); set_error1(message); return (NULL); } tri -> edgnum[0] = en0; tri -> edgnum[1] = en1; tri -> edgnum[2] = en2; tri -> vtxnum[0] = vn0; tri -> vtxnum[1] = vn1; tri -> vtxnum[2] = vn2; } if (!freemsdata (msd)) return (NULL); free_objects (VANITY, (short *) vanities); return (phn); }
int main(int argc,char ** argv) { int i; char * temp; build_defaults(); bootstrap_HMMer2(); strip_out_standard_options(&argc,argv,show_help,show_version); if( (temp = strip_out_assigned_argument(&argc,argv,"gap")) != NULL ) gap_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"g")) != NULL ) gap_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"ext")) != NULL ) ext_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"e")) != NULL ) ext_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"matrix")) != NULL ) matrix_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"m")) != NULL ) matrix_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"s")) != NULL ) qstart_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"t")) != NULL ) qend_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"aln")) != NULL ) aln_number_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"codon")) != NULL ) codon_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"alg")) != NULL ) alg_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"aalg")) != NULL ) aln_alg_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"cut")) != NULL ) search_cutoff_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"ecut")) != NULL ) evalue_search_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"subs")) != NULL ) subs_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"indel")) != NULL ) indel_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"init")) != NULL ) startend_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"alln")) != NULL ) allN_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"null")) != NULL ) null_string = temp; if( (strip_out_boolean_argument(&argc,argv,"dnas")) == TRUE ) use_single_dna = TRUE; if( (strip_out_boolean_argument(&argc,argv,"dnadb")) == TRUE ) use_single_dna = FALSE; if( (strip_out_boolean_argument(&argc,argv,"tfor")) == TRUE ) do_forward_only = TRUE; if( (strip_out_boolean_argument(&argc,argv,"flati")) == TRUE ) flat_insert = TRUE; if( (strip_out_boolean_argument(&argc,argv,"hmmer")) == TRUE ) use_tsm = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pfam2")) == TRUE ) use_pfam1 = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pfam")) == TRUE ) use_pfam2 = TRUE; if( (strip_out_boolean_argument(&argc,argv,"protein")) == TRUE ) use_single_pro = TRUE; if( (strip_out_boolean_argument(&argc,argv,"prodb")) == TRUE ) use_db_pro = TRUE; if( (temp = strip_out_assigned_argument(&argc,argv,"hname")) != NULL ) hmm_name = temp; if( (strip_out_boolean_argument(&argc,argv,"nohis")) != FALSE ) show_histogram = FALSE; if( (strip_out_boolean_argument(&argc,argv,"pretty")) != FALSE ) show_pretty = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pep")) != FALSE ) show_pep = TRUE; if( (strip_out_boolean_argument(&argc,argv,"mul")) != FALSE ) make_anchored_aln = TRUE; if( (strip_out_boolean_argument(&argc,argv,"para")) != FALSE ) show_para = TRUE; if( (strip_out_boolean_argument(&argc,argv,"sum")) != FALSE ) show_match_sum = TRUE; if( (strip_out_boolean_argument(&argc,argv,"alb")) != FALSE ) show_AlnBlock = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pal")) != FALSE ) show_PackAln = TRUE; if( (temp = strip_out_assigned_argument(&argc,argv,"divide")) != NULL ) divide_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"block")) != NULL ) main_block_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"report")) != NULL ) report_str = temp; dbsi = new_DBSearchImpl_from_argv(&argc,argv); dpri = new_DPRunImpl_from_argv(&argc,argv); strip_out_remaining_options_with_warning(&argc,argv); if( argc != 3 ) { warn("Wrong number of arguments (expect 2)!\n"); if( argc > 1 ){ warn("Arg line looked like (after option processing)"); for(i=1;i<argc;i++) { fprintf(stderr," %s\n",argv[i]); } } show_short_help(); } if( show_pretty == FALSE && show_AlnBlock == FALSE && show_PackAln == FALSE && show_pep == FALSE ) { show_pretty = TRUE; show_para = TRUE; } if( use_db_pro == FALSE && use_single_pro == FALSE && use_tsm == FALSE && use_pfam1 == FALSE && use_pfam2 == FALSE ) { use_single_pro = TRUE; } if( use_single_pro == TRUE || use_tsm == TRUE ) { if( use_single_dna == TRUE ) fatal("one on one search. Shouldn't you use pcwise?"); search_mode = PC_SEARCH_S2DB; } else { if( use_single_dna == TRUE ) search_mode = PC_SEARCH_DB2S; else search_mode = PC_SEARCH_DB2DB; } if( evalue_search_str != NULL && search_mode != PC_SEARCH_S2DB ) { fatal("Trying to set a evalue cutoff on a non evalue based search. you can only use evalues in a protein HMM vs DNA database search (sorry!)"); } if( make_anchored_aln == TRUE && search_mode != PC_SEARCH_S2DB ) { fatal("Trying to make an anchored alignment and not in single search mode"); } if( make_anchored_aln == TRUE) { do_complete_analysis = TRUE; } /* pick up remaining args and do it */ dna_seq_file = argv[2]; protein_file = argv[1]; if( build_objects() == FALSE) fatal("Could not build objects!"); if( build_db_objects() == FALSE) fatal("Could not build database-ready objects!"); show_header(stdout); if( search_db() == FALSE) warn("Could not search database"); show_output(); free_objects(); return 0; }