+
Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions bntseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,26 @@ bntseq_t *bns_restore(const char *prefix)
bns = bns_restore_core(ann_filename, amb_filename, pac_filename);
if (bns == 0) return 0;
if ((fp = fopen(strcat(strcpy(alt_filename, prefix), ".alt"), "r")) != 0) { // read .alt file if present
char str[1024];
// Seek to end of regular, non-binary, file
off_t alt_file_size;
if (fseeko(fp, 0, SEEK_END) != 0) {
return 0;
}

// Get file size
alt_file_size = ftello(fp);
if (alt_file_size == -1) {
return 0;
}

// Allocate adequate memory to store .alt file
char *str = (char*)calloc(alt_file_size, sizeof(char));
if (str == NULL) {
return 0;
}
// Seek back to beginning of file to be read
fseeko(fp, 0, SEEK_SET);

khash_t(str) *h;
int c, i, absent;
khint_t k;
Expand All @@ -197,10 +216,11 @@ bntseq_t *bns_restore(const char *prefix)
}
while (c != '\n' && c != EOF) c = fgetc(fp);
i = 0;
} else str[i++] = c; // FIXME: potential segfault here
} else str[i++] = c;
}
kh_destroy(str, h);
fclose(fp);
free(str);
}
return bns;
}
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载