/* * find a label, given it's name. if the label is not * found, it is added to the label table */ Label* get_label(Assembly* assembly, char* name) { static int id = 0; Label* label; /* find it */ label = (Label*)HT_Find(assembly->labels, name); if (!label) { /* not found, create */ label = (Label*)malloc(sizeof(Label)); label->name = malloc(strlen(name)+1); strcpy(label->name, name); label->segment = UNKNOWN; label->location = 0; label->exported = FALSE; label->imported = FALSE; label->debuginfo = LABEL_DEBUG_NONE; label->accessed = 0; label->id = ++id; label->ref = 0; /* add */ HT_Add(assembly->labels, label, name); } else { label->accessed++; } /* return */ return label; }
void inventory_add(const char* name){ HT_Add(g_inventory, 1, name); }