X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcmd.c;h=6c2c63fa85d75214ab0868d1599219bf2a1c7b8b;hb=0d225ac1f580c59da7a063ef52da35c0af254dd3;hp=eff58de1cdcaea5be3172c7bea992e4cae098030;hpb=288d61424576d1aae956ea8e4b5fb89dc25909db;p=YACASL2.git diff --git a/src/cmd.c b/src/cmd.c index eff58de..6c2c63f 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,3 +1,7 @@ +#include "cmem.h" +#include "cerr.h" +#include "hash.h" +#include "word.h" #include "casl2.h" CMD comet2cmd[] = { @@ -48,17 +52,23 @@ CMDTAB **cmdtype_code, **code_type; /* 命令と命令タイプからハッシュ値を生成する */ unsigned hash_cmdtype(const char *cmd, CMDTYPE type) { HKEY *keys[2]; + unsigned hashval; /* 命令をセット */ - keys[0] = malloc_chk(sizeof(HKEY), "hash_cmdtype.key"); + keys[0] = malloc_chk(sizeof(HKEY), "hash_cmdtype.keys[0]"); keys[0]->type = CHARS; - keys[0]->val.s = strdup_chk(cmd, "keys[0].val"); + keys[0]->val.s = strdup_chk(cmd, "keys[0].val.s"); /* 命令タイプをセット */ - keys[1] = malloc_chk(sizeof(HKEY), "hash_cmdtype.key"); + keys[1] = malloc_chk(sizeof(HKEY), "hash_cmdtype.keys[1]"); keys[1]->type = INT; keys[1]->val.i = (int)(type & 070); + /* ハッシュ値の計算 */ + hashval = hash(2, keys, cmdtabsize); + free_chk(keys[0]->val.s, "keys[0].val.s"); + free_chk(keys[0], "keys[0]"); + free_chk(keys[1], "keys[1]"); /* ハッシュ値を返す */ - return hash(2, keys, cmdtabsize); + return hashval; } /* 命令と命令タイプがキーのハッシュ表を作成する */ @@ -112,11 +122,11 @@ void free_cmdtype_code() np = cmdtype_code[i]; while(np != NULL) { nq = np->next; - free(np); + free_chk(np, "free_cmdtype_code.np"); np = nq; } } - free(cmdtype_code); + free_chk(cmdtype_code, "cmdtype_code"); } /* 命令コードからハッシュ値を生成する */ @@ -180,9 +190,9 @@ void free_code_type() np = code_type[i]; while(np != NULL) { nq = np->next; - free(np); + free_chk(np, "np"); np = nq; } } - free(code_type); + free_chk(code_type, "code_type"); }