X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flabel.c;h=63b6fe5dec797bd90c07aff0aab8fcfcb09e9aee;hb=be496380efb4018b38076cfadb4b790fa388a1e3;hp=2a39f41f090afecf794416d295489209fe84358a;hpb=fa032895bbf1893f1037c3329c037755866d4785;p=YACASL2.git diff --git a/src/label.c b/src/label.c index 2a39f41..63b6fe5 100644 --- a/src/label.c +++ b/src/label.c @@ -1,10 +1,3 @@ -#include -#include -#include - -#include "cerr.h" -#include "cmem.h" -#include "hash.h" #include "assemble.h" /** @@ -115,7 +108,7 @@ bool addlabel(const char *prog, const char *label, WORD adr) assert(label != NULL); LABELTAB *p; LABELARRAY *l; - unsigned hashval; + unsigned h; /* 登録されたラベルを検索。すでに登録されている場合はエラー発生 */ if(getlabel(prog, label) != 0xFFFF) { @@ -134,9 +127,8 @@ bool addlabel(const char *prog, const char *label, WORD adr) /* ラベル数を設定 */ labelcnt++; /* ハッシュ表へ追加 */ - hashval = labelhash(prog, label); - p->next = labels[hashval]; - labels[hashval] = p; + p->next = labels[h = labelhash(prog, label)]; + labels[h] = p; return true; } @@ -174,6 +166,9 @@ void freelabel() FREE(p->label->prog); FREE(p->label->label); FREE(p->label); + if(p == labels[i]) { + labels[i] = NULL; + } FREE(p); } }