// freeArgs // frees every argument in args structure void freeArgs(struct args *arguments) { free(arguments->program); string_array_free(arguments->program_args); string_array_free(arguments->pipe_args); free(arguments->out_file); free(arguments->in_file); free(arguments); }
static void free_all_variable_names(exodus_file_t* file) { string_array_free(file->node_var_names); string_array_free(file->node_set_var_names); string_array_free(file->edge_var_names); string_array_free(file->edge_set_var_names); string_array_free(file->face_var_names); string_array_free(file->face_set_var_names); string_array_free(file->elem_var_names); string_array_free(file->elem_set_var_names); string_array_free(file->side_set_var_names); }
void parse_config(char *configfile,struct mfshell_user_options *opts) { FILE *fp; char **argv = NULL; // create our own argv int argc; // create one own argc int new_items = 0; fp = fopen(configfile,"r"); if(fp == NULL) return; // getopt_long() expect at least argc >= 1 and argv[0] != NULL argv = (char**)calloc(1,sizeof(char*)); argv[0] = strdup("mediafire-shell"); argc = 1; new_items = config_file_read(fp, &argc, &argv); fprintf(stderr,"argc = %d\n", argc); parse_argv(argc, argv, opts); if(new_items > 0) { string_array_free(argv); } else { free(argv[0]); free(argv); } return; }
void fe_mesh_free(fe_mesh_t* mesh) { tagger_free(mesh->elem_sets); tagger_free(mesh->face_sets); tagger_free(mesh->edge_sets); tagger_free(mesh->node_sets); tagger_free(mesh->side_sets); if (mesh->face_nodes != NULL) { polymec_free(mesh->face_nodes); polymec_free(mesh->face_node_offsets); } ptr_array_free(mesh->blocks); string_array_free(mesh->block_names); int_array_free(mesh->block_elem_offsets); polymec_free(mesh->node_coords); polymec_free(mesh); }
gint main(gint argc, gchar **argv) #endif { gint i, j, c, iterations = 1; StringArray *tests_to_run = NULL; gdouble time_start; gboolean report_time = FALSE; gboolean quiet = FALSE; gboolean global_failure = FALSE; gboolean no_final_time_labels = FALSE; gboolean debug = FALSE; #if HAVE_GETOPT_H static struct option long_options [] = { {"help", no_argument, 0, 'h'}, {"time", no_argument, 0, 't'}, {"quiet", no_argument, 0, 'q'}, {"iterations", required_argument, 0, 'i'}, {"debug", no_argument, 0, 'd'}, {"no-labels", no_argument, 0, 'n'}, {0, 0, 0, 0} }; while((c = getopt_long(argc, argv, "dhtqni:", long_options, NULL)) != -1) { switch(c) { case 'h': print_help(argv[0]); return 1; case 't': report_time = TRUE; break; case 'i': iterations = atoi(optarg); break; case 'q': quiet = TRUE; break; case 'n': no_final_time_labels = TRUE; break; case 'd': debug = TRUE; break; } } for (i = optind; i < argc; i++) { if (argv[i][0] == '-') { continue; } tests_to_run = string_array_append(tests_to_run, argv[i]); } #endif time_start = get_timestamp(); for (j = 0; test_groups[j].name != NULL; j++) { gboolean run = TRUE; gchar *tests = NULL; gchar *group = NULL; if (tests_to_run != NULL) { gint k; run = FALSE; for (k = 0; k < tests_to_run->length; k++) { gchar *user = tests_to_run->strings[k]; const gchar *table = test_groups[j].name; size_t user_len = strlen(user); size_t table_len = strlen(table); if (strncmp(user, table, table_len) == 0) { if (user_len > table_len && user[table_len] != ':') { break; } run = TRUE; group = tests_to_run->strings[k]; break; } } } if (run) { gboolean passed; gchar **split = NULL; if (debug && test_groups[j].handler != fake_tests_init) { printf("Skipping %s, in driver debug mode\n", test_groups[j].name); continue; } else if (!debug && test_groups[j].handler == fake_tests_init) { continue; } if (group != NULL) { split = eg_strsplit(group, ":", -1); if (split != NULL) { gint m; for (m = 0; split[m] != NULL; m++) { if (m == 1) { tests = strdup(split[m]); break; } } eg_strfreev(split); } } passed = run_group(&(test_groups[j]), iterations, quiet, report_time, tests); if (tests != NULL) { g_free(tests); } if (!passed && !global_failure) { global_failure = TRUE; } } } if (!quiet) { gdouble pass_percentage = ((gdouble)global_passed / (gdouble)global_tests) * 100.0; printf("=============================\n"); printf("Overall result: %s : %d / %d (%g%%)\n", global_failure ? "FAILED" : "OK", global_passed, global_tests, pass_percentage); } if (report_time) { gdouble duration = get_timestamp() - time_start; if (no_final_time_labels) { printf("%g\n", duration); } else { printf("%s Total Time: %g\n", DRIVER_NAME, duration); } } if (tests_to_run != NULL) { string_array_free(tests_to_run); } return global_tests - global_passed; }