struct function * module_get_or_create_function(struct module *m, struct symbol *sym) { struct function *fun; if (ht_get_entry(m->funtable, sym->name, &fun) != 0) { fun = fun_new(sym); ht_add_entry(m->funtable, sym->name, fun); list_append(m->funlist, fun); if (!strcmp(sym->name, "main")) { check_main_prototype(sym); } } return fun; }
int give_to_client(t_cli *c, enum e_rsrc type, int quantity) { t_item *item; char const *str; if (!c || !c->inventory || quantity <= 0 || !(str = get_rsrc_string_from_enum(type))) return (0); if (!(item = ht_get_entry(c->inventory, str, strlen(str)))) { if (!(item = new_t_item(type, quantity))) return (TRACE("new_t_item() failed"), 0); if (!ht_add_entry(c->inventory, item, str, strlen(str))) return (TRACE("ht_add_entry() failed"), free(item), 0); } else item->amount += quantity; return (quantity); }