From 33b2db1c6042ef40aace870b3dc62bf7f97a66ec Mon Sep 17 00:00:00 2001 From: Clyybber Date: Wed, 2 Oct 2019 00:02:03 +0200 Subject: [PATCH] Prepare for csize to be uint See https://github.com/nim-lang/Nim/pull/12321 --- src/hts/bam.nim | 2 +- src/hts/bgzf/bgzi.nim | 2 +- src/hts/vcf.nim | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hts/bam.nim b/src/hts/bam.nim index f609273..6136854 100644 --- a/src/hts/bam.nim +++ b/src/hts/bam.nim @@ -67,7 +67,7 @@ proc from_string*(r:Record, record_string:string) = raise newException(ValueError, "must create record with NewRecord before calling from_string") - var kstr = kstring_t(s:record_string.cstring, m:record_string.len, l:record_string.len) + var kstr = kstring_t(s:record_string.cstring, m:record_string.len.csize, l:record_string.len.csize) var ret = sam_parse1(kstr.addr, r.hdr.hdr, r.b) if ret != 0: raise newException(ValueError, "error:" & $ret & " in from_string parsing record: " & record_string) diff --git a/src/hts/bgzf/bgzi.nim b/src/hts/bgzf/bgzi.nim index a33979c..b3320fe 100644 --- a/src/hts/bgzf/bgzi.nim +++ b/src/hts/bgzf/bgzi.nim @@ -51,7 +51,7 @@ iterator query*(bi: BGZI, chrom: string, start:int, stop:int): string {.inline.} fastSubStr(outstr, kstr.s, 0, int(kstr.l)) yield outstr hts_itr_destroy(itr) - assert kstr.l >= 0 + assert int(kstr.l) >= 0 free(kstr.s) assert fn.addr != nil diff --git a/src/hts/vcf.nim b/src/hts/vcf.nim index 8a3d873..b44c35f 100644 --- a/src/hts/vcf.nim +++ b/src/hts/vcf.nim @@ -199,7 +199,7 @@ proc toSeq[T](data: var seq[T], p:pointer, n:int) {.inline.} = if data.len != n: data.set_len(n) if n == 0: return - copyMem(data[0].addr, p, (n * sizeof(T).csize)) + copyMem(data[0].addr, p, csize(n * sizeof(T))) proc bcf_hdr_id2type(hdr:ptr bcf_hdr_t, htype:int, int_id:int): int {.inline.}= # translation of htslib macro. @@ -403,7 +403,7 @@ proc destroy_variant(v:Variant) = free(v.p) proc from_string*(v: var Variant, h: Header, s:var string) = - var str = kstring_t(s:s.cstring, l:s.len, m:s.len) + var str = kstring_t(s:s.cstring, l:s.len.csize, m:s.len.csize) if v == nil: new(v, destroy_variant) if v.c == nil: