void f_string_print_memory(const t_string *v_this, const char *name) { if (name != NULL) M_INFOS(name); else M_INFOS("string"); uf_print_memory(v_this->v_str, v_this->v_capacity); }
void uf_free_s(void **ptr) { if (*ptr == NULL) M_INFOS("ptr == NULL"); free(*ptr); *ptr = NULL; }
bool f_vector_push_back(t_vector *v_this, void *data) { t_ui new_size; if (data == NULL) M_INFOS("Null pointer"); new_size = v_this->f_realloc(v_this->v_size); if (v_this->v_size + 1 > v_this->v_capacity && D_VECTOR(realloc)(v_this, new_size) == false) return (false); v_this->v_data[v_this->v_size] = data; v_this->v_size = v_this->v_size + 1; return (true); }
void tf_launch(const char *name, void (*sort)(int *, size_t)) { t_timer timer; int ptr_int[SIZE_TAB]; M_INFOS(name); uf_init(ptr_int); D_TIMER(start)(&timer); sort(ptr_int, SIZE_TAB); D_TIMER(pause)(&timer); if (uf_check_if_tab_is_sorted(ptr_int) == true) { uf_print_nbr(D_TIMER(get_ticks)(&timer)); uf_print_str(" milliseconds\n\n"); } else uf_print_tab(ptr_int); }
void f_threadpool_destroy(t_threadpool *v_this) { size_t i; t_threadpool_data *data; i = 0; if (D_LOCK(lock)(&v_this->v_data, (void **)&data) == true) { data->v_run = false; D_LOCK(release)(&v_this->v_data, (void **)&data); } while (i < v_this->v_nb_thread) { if (pthread_join(v_this->v_id[i], NULL) != 0) M_INFOS("pthread_join error"); i = i + 1; } D_LOCK(destroy)(&v_this->v_data); D_QUEUE(destroy)(&v_this->pv_data.v_tasks); uf_free_s((void **)&v_this->v_id); }