char *factoid_get(array *args, struct irc_message *msg) { const char *value; if (array_count(args) < 1) return NULL; value = strmap_find(&factoids, *(char**)array_at(args, 0)); if (value == NULL) return NULL; return new_string(value); }
/* * Remove record r */ void strmap_erase(strmap_t *hmap, strmap_rec_t *r) { assert(strmap_find(hmap, r->key) == r); string_decref(r->key); r->key = DELETED_KEY; hmap->nelems --; hmap->ndeleted ++; if (hmap->ndeleted > hmap->cleanup_threshold) { strmap_cleanup(hmap); } }
void push_label(const char* name) { Function* curf = cur_func(); // check if label already exists Label** foundl = strmap_find(curf->labels, name); if(foundl != NULL) yyerrerf("A label with the name '%s' has already been defined in function '%s'.", name, curf->name); /*llist_foreach(LabelList, curf->labels, l) { if(strcmp(l->name, name) == 0) { } }*/ Label* l = new_label(name); curlabels = llist_prepend(l, curlabels); strmap_insert(curf->labels, name, l); //curf->labels = llist_prepend(l, curf->labels); }