int init_user_list( struct linked_list **curr ) { char directory_name[NAME_LEN]; struct linked_list *head = NULL; struct linked_list *activity_list; if (list_fs_elements(CONF_DATASET_DIRECTORY, DT_DIR, &activity_list)) return EXIT_FAILURE; while (activity_list) { struct linked_list *subdir_list; snprintf(directory_name, NAME_LEN, "%s/%s", CONF_DATASET_DIRECTORY, activity_list->name); if (list_fs_elements(directory_name, DT_DIR, &subdir_list)) return EXIT_FAILURE; while (subdir_list) { if (linked_list_contains(head, subdir_list->name) == -1) linked_list_push(&head, subdir_list->name); subdir_list = subdir_list->next; } linked_list_free(subdir_list); activity_list = activity_list->next; } linked_list_free(activity_list); *curr = head; return EXIT_SUCCESS; }
void x86_loader_free(struct x86_loader_t *loader) { /* Check no more links */ assert(!loader->num_links); /* Free ELF file */ if (loader->elf_file) elf_file_free(loader->elf_file); /* Free arguments */ LINKED_LIST_FOR_EACH(loader->args) str_free(linked_list_get(loader->args)); linked_list_free(loader->args); /* Free environment variables */ LINKED_LIST_FOR_EACH(loader->env) str_free(linked_list_get(loader->env)); linked_list_free(loader->env); /* Free loader */ str_free(loader->interp); str_free(loader->exe); str_free(loader->cwd); str_free(loader->stdin_file); str_free(loader->stdout_file); free(loader); }
int netbench_master_run(int rank, int clientsnb, options_t opts) { int tmp; struct linked_list *results; struct linked_list *process; results = linked_list_init(); process = linked_list_init(); tmp = 0; while (tmp < clientsnb) { if (tmp == rank) { tmp++; continue; } linked_list_add(process,linked_list_proc_value_init( netbench_comm_proc_recv(tmp) )); tmp++; } netbench_algo_run_master(NETBENCH_ALGO_MATRIX,results,clientsnb); netbench_printer_print(process, results, clientsnb,opts); linked_list_free(results); linked_list_free(process); return 0; }
void bed_close(bed_file_t *bed_file, int free_records) { // Free header entries linked_list_free(bed_file->header_entries, NULL); // TODO doesn't work! :( // Free records list if asked to if (free_records) { linked_list_free(bed_file->records, bed_record_free); } munmap((void*) bed_file->data, bed_file->data_len); free(bed_file); }
void event_free(event_t * event) { linked_list_node_t * node; for(node = linked_list_first(event->all_event); node; node = linked_list_next(node)) { free(linked_list_data(node)); } linked_list_free(event->all_event); linked_list_free(event->el.list); }
void hash_map_free(hash_map *map) { for (size_t i = 0; i < map->capacity; i++) { if (map->table[i]) { linked_list_free(map->table[i]); } } linked_list_free(map->keys); safe_free(map->table); safe_free(map); }
/** * Destroy BAM framework data structure. */ void bfwork_destroy(bam_fwork_t *fwork) { int i; bam_region_t *region; linked_list_t *list; size_t list_l; assert(fwork); assert(fwork->regions_list); //Handle to list list = fwork->regions_list; //Regions exists? if(fwork->regions_list) { //for(i = 0; i < wanderer->regions_l; i++) list_l = linked_list_size(list); for(i = 0; i < list_l; i++) { //Get region region = linked_list_get(i, list); breg_destroy(region, 1); free(region); } linked_list_free(list, NULL); } //Destroy lock omp_destroy_lock(&fwork->regions_lock); omp_destroy_lock(&fwork->output_file_lock); omp_destroy_lock(&fwork->reference_lock); }
void si_gpu_done() { struct si_compute_unit_t *compute_unit; int compute_unit_id; /* GPU pipeline report */ si_gpu_dump_report(); /* Free stream cores, compute units, and device */ SI_GPU_FOREACH_COMPUTE_UNIT(compute_unit_id) { compute_unit = si_gpu->compute_units[compute_unit_id]; si_compute_unit_free(compute_unit); } free(si_gpu->compute_units); /* List of removed instructions */ si_gpu_uop_trash_empty(); linked_list_free(si_gpu->trash_uop_list); /* Free GPU */ free(si_gpu); /* Finalizations */ si_uop_done(); }
/* Finalization */ void x86_cpu_done() { int core; /* Dump CPU report */ x86_cpu_dump_report(); /* Uop trace list */ x86_cpu_uop_trace_list_empty(); linked_list_free(x86_cpu->uop_trace_list); /* Finalize structures */ x86_fetch_queue_done(); x86_uop_queue_done(); x86_rob_done(); x86_iq_done(); x86_lsq_done(); x86_event_queue_done(); x86_bpred_done(); x86_trace_cache_done(); x86_reg_file_done(); x86_fu_done(); /* Free processor */ X86_CORE_FOR_EACH x86_cpu_core_done(core); free(x86_cpu->core); free(x86_cpu); }
void net_buffer_free(struct net_buffer_t *buffer) { list_free(buffer->msg_list); linked_list_free(buffer->wakeup_list); free(buffer->name); free(buffer); }
void remove_duplicates_in_place(LinkedList *list) { if (NULL == list) return; LinkedList *tail = list; while (NULL != tail->next) tail = tail->next; LinkedList *test_node = tail; while (NULL != test_node) { while (NULL != test_node->next) { LinkedList *next = test_node->next; if (test_node->value > next->value) { // Switch two nodes. if (NULL != next->next) next->next->prev = test_node; if (NULL != test_node->prev) test_node->prev->next = next; next->prev = test_node->prev; test_node->next = next->next; test_node->prev = next; next->next = test_node; } else if (test_node->value == next->value) { // Found duplicates! if (NULL != test_node->prev) test_node->prev->next = next; next->prev = test_node->prev; test_node->next = NULL; linked_list_free(test_node); break; } else { break; } } test_node = test_node->prev; } }
void arch_free(struct arch_t *arch) { free(arch->name); free(arch->prefix); linked_list_free(arch->mem_entry_mod_list); free(arch); }
static void cleanup_device(osprd_info_t *d) { wake_up_all(&d->blockq); if (d->gd) { del_gendisk(d->gd); put_disk(d->gd); } if (d->queue) blk_cleanup_queue(d->queue); if (d->data) vfree(d->data); linked_list_free(&d->read_locking_pids); linked_list_free(&d->invalid_tickets); d->passwd_hash = 0; }
void scopes_tree_free (scopes_tree tree) { assert_tree (tree); if (tree->t.children_num != 0) { for (uint8_t i = 0; i < tree->t.children_num; ++i) { scopes_tree_free (*(scopes_tree *) linked_list_element (tree->t.children, i)); } linked_list_free (tree->t.children); } linked_list_free (tree->instrs); linked_list_free (tree->var_decls); jsp_mm_free (tree); }
void evg_faults_done(void) { while (linked_list_count(evg_fault_list)) { linked_list_head(evg_fault_list); free(linked_list_get(evg_fault_list)); linked_list_remove(evg_fault_list); } linked_list_free(evg_fault_list); }
void linked_list_free (linked_list list) { ASSERT_LIST (list); linked_list_header *header = (linked_list_header *) list; if (header->next) { linked_list_free ((linked_list) header->next); } mem_heap_free_block (list); }
void linked_list_free (linked_list list) { ASSERT_LIST (list); linked_list_header *header = (linked_list_header *) list; if (header->next) { linked_list_free ((linked_list) header->next); } jsp_mm_free (list); }
void X86CoreFreeEventQueue(X86Core *self) { struct x86_uop_t *uop; while (linked_list_count(self->event_queue)) { uop = X86CoreExtractFromEventQueue(self); x86_uop_free_if_not_queued(uop); } linked_list_free(self->event_queue); }
/* Free command queue */ void evg_opencl_command_queue_free(struct evg_opencl_command_queue_t *command_queue) { /* Check that command list is empty */ if (linked_list_count(command_queue->command_list)) fatal("%s: freed command queue is not empty", __FUNCTION__); /* Free */ evg_opencl_repo_remove_object(evg_emu->opencl_repo, command_queue); linked_list_free(command_queue->command_list); free(command_queue); }
void frm_emu_done(void) { /* Free CUDA object list */ frm_cuda_object_free_all(); linked_list_free(frm_cuda_object_list); frm_isa_done(); mem_free(frm_emu->const_mem); mem_free(frm_emu->global_mem); free(frm_emu); }
void hash_map_clear(hash_map *map) { for (size_t i = 0; i < map->capacity; i++) { linked_list *list = map->table[i]; if (list) { linked_list_free(list); map->table[i] = NULL; } } map->size = 0; }
int main() { MemoryPool *pool = memory_pool_init(sizeof(100)*100); LinkedList *number_a = NULL; number_a = linked_list_append(number_a, memory_pool_alloc_int(pool, 3)); number_a = linked_list_append(number_a, memory_pool_alloc_int(pool, 1)); number_a = linked_list_append(number_a, memory_pool_alloc_int(pool, 5)); linked_list_print(number_a); LinkedList *number_b = NULL; number_b = linked_list_append(number_b, memory_pool_alloc_int(pool, 5)); number_b = linked_list_append(number_b, memory_pool_alloc_int(pool, 9)); number_b = linked_list_append(number_b, memory_pool_alloc_int(pool, 2)); number_b = linked_list_append(number_b, memory_pool_alloc_int(pool, 1)); linked_list_print(number_b); LinkedList *result = add(number_a, number_b, pool); linked_list_print(result); linked_list_free(result); linked_list_free(number_b); linked_list_free(number_a); memory_pool_free(pool); return 0; }
int main (int argc, char ** argv) { if (argc != 2) { fprintf (stderr, "usage: %s <N>\n", argv[0]); return 1; } int N = atoi (argv[1]); if (N < 1) return 1; int count = 0; for (int i = 1; i <= N; i++) { cf_sqrt_step_t frac; frac.num = i; frac.step = 0; linked_list_t * fractions = linked_list_create (); // All quadratic irrationals must eventually reach a cycle while (cf_expand_sqrt_continued_fraction (&frac)) { cf_sqrt_step_t * f = NULL; bool cycle_found = false; while ((f = linked_list_next (fractions, cf_sqrt_step_t)) != NULL) if (cf_sqrt_steps_identical (f, &frac)) { cycle_found = true; int cycle_len = frac.step - f->step; if (cycle_len % 2 == 1) count++; linked_list_stop_iteration (fractions); break; } if (!cycle_found) linked_list_add_copy (fractions, &frac, cf_sqrt_step_t); else break; } linked_list_free (fractions); } printf ("%d\n", count); return 0; }
void X86ThreadFreeLSQ(X86Thread *self) { struct linked_list_t *lq; struct linked_list_t *sq; struct linked_list_t *preq; struct x86_uop_t *uop; /* Load queue */ lq = self->lq; linked_list_head(lq); while (linked_list_count(lq)) { uop = linked_list_get(lq); uop->in_lq = 0; linked_list_remove(lq); x86_uop_free_if_not_queued(uop); } linked_list_free(lq); /* Store queue */ sq = self->sq; linked_list_head(sq); while (linked_list_count(sq)) { uop = linked_list_get(sq); uop->in_sq = 0; linked_list_remove(sq); x86_uop_free_if_not_queued(uop); } linked_list_free(sq); /* Prefetch queue */ preq = self->preq; linked_list_head(preq); while (linked_list_count(preq)) { uop = linked_list_get(preq); uop->in_preq = 0; linked_list_remove(preq); x86_uop_free_if_not_queued(uop); } linked_list_free(preq); }
void si_work_item_free(struct si_work_item_t *work_item) { /* Empty LDS output queues */ while (list_count(work_item->lds_oqa)) free(list_dequeue(work_item->lds_oqa)); while (list_count(work_item->lds_oqb)) free(list_dequeue(work_item->lds_oqb)); list_free(work_item->lds_oqa); list_free(work_item->lds_oqb); linked_list_free(work_item->write_task_list); /* Free work_item */ free(work_item); }
int main() { MemoryPool *pool = memory_pool_init(sizeof(100) * 100); LinkedList *list = NULL; list = linked_list_append(list, memory_pool_alloc_int(pool, 1)); list = linked_list_append(list, memory_pool_alloc_int(pool, 2)); list = linked_list_append(list, memory_pool_alloc_int(pool, 3)); list = linked_list_append(list, memory_pool_alloc_int(pool, 2)); list = linked_list_append(list, memory_pool_alloc_int(pool, 4)); linked_list_print(list); remove_duplicates_in_place(list); linked_list_print(list); list = linked_list_free(list); memory_pool_free(pool); return 0; }
event_list_t * event_check(event_t * event, SYSTEMTIME * ntime, SYSTEMTIME * otime) { linked_list_node_t * node = linked_list_first(event->all_event); linked_list_free(event->el.list); linked_list_create(&event->el.list); for(node; node; node = linked_list_next(node)) { struct event_em_t * em = (struct event_em_t *)linked_list_data(node); if(event_em_compare(em, ntime, otime)) linked_list_insert(event->el.list, 0, em); } return &event->el; }
void opengl_vertex_array_obj_repo_free(struct linked_list_t *vao_repo) { opengl_debug("\tFree VAO repository [%p]\n", vao_repo); struct opengl_vertex_array_obj_t *vao; /* Free all elements */ LINKED_LIST_FOR_EACH(vao_repo) { vao = linked_list_get(vao_repo); assert(vao); opengl_vertex_array_obj_free(vao); } /* Free VAO repository */ linked_list_free(vao_repo); }
void X86CpuDestroy(X86Cpu *self) { int i; FILE *f; /* Dump report */ f = file_open_for_write(x86_cpu_report_file_name); if (f) { X86CpuDumpReport(self, f); fclose(f); } /* Uop trace list */ X86CpuEmptyTraceList(self); linked_list_free(self->uop_trace_list); /* Free cores */ for (i = 0; i < x86_cpu_num_cores; i++) delete (self->cores[i]); free(self->cores); }
int main (int argc, char ** argv) { if (argc != 2) { fprintf (stderr, "usage: %s <N>\n", argv[0]); return 1; } int N = atoi (argv[1]); bool * sieve = eratosthenes_sieve (PRIMES_PRODUCT_LIMIT); size_t primes_count = count_primes (sieve, N); if (primes_count == 0) { printf ("0\n"); return 0; } int primes[primes_count]; int powers[primes_count]; fill_factor_arrays (primes, powers, sieve, primes_count); free (sieve); linked_list_t * pseudo_fortunates = linked_list_create (); int prime = 0; while ((prime = next_prime (primes, powers, primes_count, N)) > 0) { int val = find_pseudo_fortunate (prime); linked_list_add_sorted (pseudo_fortunates, copy_int (val), int_cmp, true); } int sum = linked_list_sum_int (pseudo_fortunates); printf ("%d\n", sum); linked_list_free (pseudo_fortunates); return 0; }