0
我有一個問題,這一點我的代碼:條件跳轉或移動依賴於未初始化值
unsigned long me_hash(MEntry *me, unsigned long size){
unsigned long hashval=0;
int i=0;
for(i=0; me->surname[i];i++) hashval +=me->surname[i] + 28 * hashval;;
for(i=0; me->surname[i];i++){
if(me->postcode[i]) {
hashval += me->postcode[i] + 28 * hashval;
}
}
hashval += me->house_number;
return (hashval%size);
}
當我運行Valgrind是
==4480== Conditional jump or move depends on uninitialised value(s)
==4480== at 0x8048EB7: me_hash (mentry.c:66)
==4480== by 0x8048B3E: ml_lookup (mlist.c:91)
==4480== by 0x80488D2: main (finddupl.c:43)
==4480==
我不知道這是我得到的消息知道如何解決這個問題。你可以幫幫我嗎?
'me-> surname [i];'或'me-> postcode [i]'是未初始化的?在使用前先打印看看。 – gsamaras 2014-11-08 23:29:57