valgrindから次のエラーが発生しています。条件ジャンプまたは移動は、初期化されていない値に依存します。私は似たような質問を見回しましたが、何が間違っているかを知ることはできません。私はすべての変数を初期化しましたが、まだ..条件付きジャンプまたは移動はユニオン化されていない値に依存します
unsigned long hash_word(const char *str)
{
unsigned long hash = 5381;
int c = 0;
while((c = *str)) // The error occurs here
{
hash = ((hash<<5) + hash) + c;
str++;
}
return hash%1999099;
}
strの値はmain関数から渡されます。私は、リークチェック=フルとトラック・オリジン=はいを使用しています。助けを前にありがとう。
最初にノードを初期化しています。
typedef struct node{
char word[46];
struct node *next;
} node;
呼び出し元のコードが
while(!(feof(fp)))
{
node *n = malloc(sizeof(node));
if (n == NULL)
{
return false;
}
else
{
fscanf(fp,"%s",n->word);
index = hash_word(n->word);
.
.
. // further code
}
'str'はどのように入手できますか?私たちに発信者コードを表示してください。 – cnicutar