diff --git a/src/sbbs3/smbutil.c b/src/sbbs3/smbutil.c index 199fa4b3801fe66baf85d85d277a9be7fcf94e33..0196381b90b9d95e64135433516daf3142a98b70 100644 --- a/src/sbbs3/smbutil.c +++ b/src/sbbs3/smbutil.c @@ -708,9 +708,10 @@ void maint(void) hash_t* hashes = malloc(max_hashes * SMB_HASH_SOURCE_TYPES * sizeof(hash_t)); if(hashes != NULL) { if(fread(hashes, sizeof(hash_t), max_hashes * SMB_HASH_SOURCE_TYPES, smb.hash_fp) == max_hashes * SMB_HASH_SOURCE_TYPES) { - CHSIZE_FP(smb.hash_fp,0); rewind(smb.hash_fp); fwrite(hashes, sizeof(hash_t), max_hashes * SMB_HASH_SOURCE_TYPES, smb.hash_fp); + fflush(smb.hash_fp); + CHSIZE_FP(smb.hash_fp, sizeof(hash_t) * max_hashes * SMB_HASH_SOURCE_TYPES); } free(hashes); } @@ -860,15 +861,16 @@ void maint(void) printf("Re-writing index...\n"); rewind(smb.sid_fp); - CHSIZE_FP(smb.sid_fp,0); for(m=n=0;m<l;m++) { if(idx[m].attr&MSG_DELETE) continue; - printf("%lu of %lu\r",++n,l-flagged); + n++; + printf("%lu of %lu\r", n, l-flagged); fwrite(&idx[m],sizeof(idxrec_t),1,smb.sid_fp); } - printf("\nDone.\n\n"); fflush(smb.sid_fp); + CHSIZE_FP(smb.sid_fp, n * sizeof(idxrec_t)); + printf("\nDone.\n\n"); free(idx); smb.status.total_msgs-=flagged;