void insert(hash_table_t table, app_pc addr, cbr_state_t state) { elem_t *elem = new_elem(addr, state); uint index = hash_func(addr); list_t *list = table[index]; if (list == NULL) { list = new_list(); table[index] = list; } append_elem(list, elem); }
char read_files(t_explorer *explorer) { DIR *dirp; struct dirent *dirent_p; explorer->files = NULL; dirp = NULL; if (NULL == (dirp = opendir(explorer->current_path))) return (0); while (NULL != (dirent_p = readdir(dirp))) { if (my_strcmp(dirent_p->d_name, ".")) append_elem(&explorer->files, dirent_p->d_name); } return (1); }
void init_bts2(t_linkedlist **bts, t_bunny_pixelarray *buff) { append_elem(bts, init_bt(buff, buttons_erase(), &on_eraser_click)); append_elem(bts, init_bt(buff, buttons_more_border(), &on_plus_click)); append_elem(bts, init_bt(buff, buttons_less_border(), &on_less_click)); append_elem(bts, init_bt(buff, buttons_clean_border(), &on_reset_workplan_click)); append_elem(bts, init_bt(buff, buttons_color(), &on_palette_click)); append_elem(bts, init_bt(buff, buttons_load(), &on_load_tkp_click)); append_elem(bts, init_bt(buff, buttons_save(), &on_save_tkp_click)); append_elem(bts, init_bt(buff, buttons_load_bmp(), &on_load_bmp_click)); }
/** * @precondition IO: File stream points to first byte of RAW data. * @postcondition IO: File stream points to first byte of next * or EOF. */ static int memorize_raw_eb(pfi_raw_t pfi_raw, pdd_data_t pdd, list_t *raw_pebs, io_t io) { int rc = 0; uint32_t i; size_t read, to_read, eb_num; size_t bytes_left; list_t pebs = *raw_pebs; peb_t peb = NULL; long old_file_pos = ftell(io->fp_pfi); for (i = 0; i < pfi_raw->starts_size; i++) { bytes_left = pfi_raw->data_size; rc = fseek(io->fp_pfi, old_file_pos, SEEK_SET); if (rc != 0) goto err; eb_num = byte_to_blk(pfi_raw->starts[i], pdd->eb_size); while (bytes_left) { to_read = MIN(bytes_left, pdd->eb_size); rc = peb_new(eb_num++, pdd->eb_size, &peb); if (rc != 0) goto err; read = fread(peb->data, 1, to_read, io->fp_pfi); if (read != to_read) { rc = -EIO; goto err; } pebs = append_elem(peb, pebs); bytes_left -= read; } } *raw_pebs = pebs; return 0; err: pebs = remove_all((free_func_t)&peb_free, pebs); return rc; }
void init_bts(t_linkedlist **bts, t_bunny_pixelarray *buff) { *bts = NULL; append_elem(bts, init_bt(buff, buttons_pen_border(), &on_pen_click)); append_elem(bts, init_bt(buff, buttons_circle_border(), &on_circle_click)); append_elem(bts, init_bt(buff, buttons_empty_circle_border(), &on_empty_circle_click)); append_elem(bts, init_bt(buff, buttons_square_border(), &on_square_click)); append_elem(bts, init_bt(buff, buttons_empty_square_border(), &on_empty_square_click)); append_elem(bts, init_bt(buff, buttons_line_border(), &on_line_click)); init_bts2(bts, buff); }
/** * Register a callback function that will be triggered on the specified PE * *whenever* the specified condition is raised */ int CcdCallOnConditionKeepOnPE(int condnum, CcdVoidFn fnp, void *arg, int pe) { return append_elem(&(CpvAccess(conds).condcb_keep[condnum]), fnp, arg, pe); }
/** * Register a callback function that will be triggered *whenever* the specified * condition is raised */ int CcdCallOnConditionKeep(int condnum, CcdVoidFn fnp, void *arg) { return append_elem(&(CpvAccess(conds).condcb_keep[condnum]), fnp, arg, CcdIGNOREPE); }