X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=blobdiff_plain;f=src%2Fcmd.c;h=7c1e803ea275554c96dfd138fe2c3edb8a6f4d54;hp=d684d06ba403c7c074f1eb8aa6bee244523b1e15;hb=e24285f0509319319aef28a188b7c01ba7e22bf1;hpb=7a360e7f77580a2504ed331c6b23c392bd62f4cc diff --git a/src/cmd.c b/src/cmd.c index d684d06..7c1e803 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -42,7 +42,8 @@ CMDCODEARRAY cmdcodearray[] = { }; int cmdcodesize = ARRAYSIZE(cmdcodearray); -CMDCODETAB *cmdtype_code[ARRAYSIZE(cmdcodearray)], *code_type[ARRAYSIZE(cmdcodearray)]; +int hashtabsize; +CMDCODETAB **cmdtype_code, **code_type; /* 命令と命令タイプからハッシュ値を生成する */ unsigned hash_cmdtype(const char *cmd, CMDTYPE type) { @@ -67,8 +68,10 @@ bool create_cmdtype_code() unsigned hashval; int i; + hashtabsize = cmdcodesize; + cmdtype_code = malloc(cmdcodesize * sizeof(CMDCODETAB *)); for(i = 0; i < cmdcodesize; i++) { - np = malloc(sizeof(CMDCODETAB *)); + np = malloc(sizeof(CMDCODETAB)); if(np == NULL) { setcerr(122, NULL); /* cannot create hash table */ return false; @@ -132,8 +135,10 @@ bool create_code_type() unsigned hashval; int i; + hashtabsize = cmdcodesize; + code_type = malloc(cmdcodesize * sizeof(CMDCODETAB *)); for(i = 0; i < cmdcodesize; i++) { - if((np = malloc(sizeof(CMDCODETAB *))) == NULL) { + if((np = malloc(sizeof(CMDCODETAB))) == NULL) { setcerr(122, NULL); /* cannot create hash table */ return false; }