X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sam_view.c;h=7f3fdabc1ca581476246e64cca85fedc8b45207e;hb=7c3295ba455fdc9269156dd1246c92ea5df3efd4;hp=c7a47747b4aba916911534591411ae0721b962a2;hpb=0ab78ddb98818366103c11330526b8a2ea33a757;p=samtools.git diff --git a/sam_view.c b/sam_view.c index c7a4774..7f3fdab 100644 --- a/sam_view.c +++ b/sam_view.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "sam_header.h" #include "sam.h" #include "faidx.h" @@ -14,7 +15,7 @@ KHASH_SET_INIT_STR(rg) // data passed to the bam_fetch callback is encapsulated in this struct. typedef struct { bam_header_t *header; - int *count; + int64_t *count; // int does overflow for very big BAMs } count_func_data_t; typedef khash_t(rg) *rghash_t; @@ -128,7 +129,7 @@ int main_samview(int argc, char *argv[]) { int c, is_header = 0, is_header_only = 0, is_bamin = 1, ret = 0, compress_level = -1, is_bamout = 0, is_count = 0; int of_type = BAM_OFDEC, is_long_help = 0, n_threads = 0; - int count = 0; + int64_t count = 0; samfile_t *in = 0, *out = 0; char in_mode[5], out_mode[5], *fn_out = 0, *fn_list = 0, *fn_ref = 0, *fn_rg = 0, *q; @@ -273,9 +274,9 @@ int main_samview(int argc, char *argv[]) } view_end: - if (is_count && ret == 0) { - printf("%d\n", count); - } + if (is_count && ret == 0) + printf("%" PRId64 "\n", count); + // close files, free and return free(fn_list); free(fn_ref); free(fn_out); free(g_library); free(g_rg); free(fn_rg); if (g_bed) bed_destroy(g_bed);