この関数はハッシュ テーブルの一部です。検索するハッシュ リストとキーを渡します。
int HashSearch (Hash_list h, char* key)
{
struct ent *x = (struct ent *)malloc(10*sizeof(struct ent));
for (x = h->table[hash(key, h->size)]; x!=0; x=x->next) {
if (strcmp(x->pos, key)==0) {
return x->num;
}
}
return -1;
}
残念ながら、実行しようとすると、valgrind でエラーが発生し続けます。
==1741== Conditional jump or move depends on uninitialised value(s)
==1741== at 0x4018DE: HashSearch (Hash.c:81)
==1741== by 0x400FA7: function (Nine13.c:181)
==1741== by 0x4009D8: main (Nine13.c:54)
==1741==
==1743== Conditional jump or move depends on uninitialised value(s)
==1743== at 0x4018DE: HashSearch (Hash.c:81)
==1743== by 0x400FA7: function (Nine13.c:181)
==1743== by 0x4009D8: main (Nine13.c:54)
==1743==
(81 行目は「for」で始まるコード行です)。
渡された と ハッシュ リストの両方を初期化したような気がstruct ent
します。何が問題なのですか?