と何が間違っていますchunk_bufferのコンテンツを何回か使用して、異なる脚線を持つチャンクの類似した指紋を生成することがあります。私の問題は、それが思わあり、以下の機能が</strong></p> <p>fpfile、<strong>rabin_polynomial</strong>構造からファイルオフセットを取得MD5フィンガープリントを生成するために</strong> INPUT_FILE <strong>を開き、<strong>に結果を書き込み、次のコード
何故その理由が考えられますか?
他の入力とmd5関数を別々にテストし、正しいダイジェストを生成しました。
int write_rabin_fingerprints_to_binary_file(FILE *fpfile,FILE *input_file,
struct rabin_polynomial *head)
{
struct rabin_polynomial *poly=head;
unsigned char fing_print[33]={'\0'};
size_t bytes_read;
while(poly != NULL)
{
char *chunk_buffer;
chunk_buffer = (char*) malloc ((poly->length));
bytes_read=fread (chunk_buffer,1, poly->length,input_file);
if(bytes_read!=poly->length)
{
printf("Error reading from%s ",input_file);
return -1;
}
strncpy((char*)fing_print,md5(chunk_buffer).c_str(),32);
size_t ret_val=fprintf(fpfile, "%llu\t%lu\t%s\n",poly->start,
poly->length,fing_print);
if(ret_val == 0)
{
fprintf(stderr, "Could not write rabin polynomials to file.");
return -1;
}
poly=poly->next_polynomial;
free(chunk_buffer);
}
return 0;
}
EDIT:
私はのmalloc()ラインにのchar *に型キャストでしたVisual Studioの2010を使用して、このプログラムを実行している問題を作成しますか?
読み取られるバイト数は、引数で指定されたとおりです。
freadの戻り値をどこかで確認する必要があります – perreal