void x_update(EV_P_ struct x_node *x0, struct x_node *x1, double *d) { struct x_node *i0, *i1; struct k_node *k; for (i0 = x0; i0 != NULL; i0 = i0->x_parent) { for (i1 = x1; i1 != NULL; i1 = i1->x_parent) { k = k_lookup(i0, i1, L_CREATE); if (k != NULL) k_update(EV_A_ k, x0, x1, d); } } }
static int translate(char *fname, char *str, int strN, char **out) { char fullname[128]; if (!strN) { *out = strdup(str); return 0; } get_sys_table_file_name(fname, fullname); if ((fp=fopen(fullname, "rb"))==NULL) p_err("cannot open %s %s", fname, fullname); struct stat st; stat(fullname, &st); N = st.st_size / sizeof(T2S); char *p=str; char *endp = str + strN; int opN=0; char *op = NULL; while (p < endp) { op = (char *)realloc(op, opN+5); opN += k_lookup(p, &op[opN]); p+=utf8_sz(p); } fclose(fp); *out = op; op[opN]=0; return opN; }
void k_destroy(EV_P_ struct x_node *x0, struct x_node *x1, int which) { struct k_node *k = k_lookup(x0, x1, 0); struct x_node *c; struct sub_node *s, *t; if (k == NULL) return; list_for_each_entry_safe(s, t, &k->k_sub_list, s_k_link) sub_cancel(EV_A_ s); hlist_del(&k->k_hash_node); free(k); nr_k--; if (which == 0) { x_for_each_child(c, x1) k_destroy(EV_A_ x0, c, which); } else { x_for_each_child(c, x0) k_destroy(EV_A_ c, x1, which); } }