Skip to content

Commit

Permalink
fix kstring new vs free
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilong-Li committed Apr 7, 2024
1 parent 80b2285 commit f942aaa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: vcfppR
Title: Rapid Manipulation of the Variant Call Format (VCF)
Version: 0.4.3
Version: 0.4.4
Authors@R: c(
person("Zilong", "Li", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5859-2078")),
Expand Down
5 changes: 3 additions & 2 deletions cleanup.win
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh

rm -f src/htslib-1.18/config.h src/*.o src/*.so src/*.dll src/*.dylib
cd src/htslib-1.18/ && make clean && cd -
HTSLIB_DIR=htslib-1.19.1
rm -f src/${HTSLIB_DIR}/config.h src/*.o src/*.so src/*.dll src/*.dylib
cd src/${HTSLIB_DIR}/ && make clean && cd -
2 changes: 1 addition & 1 deletion src/Makevars.win
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HTSLIB_DIR=htslib-1.18
HTSLIB_DIR=htslib-1.19.1
PKG_CPPFLAGS=-I. -I${HTSLIB_DIR} -D_FILE_OFFSET_BITS=64
PKG_LIBS=${HTSLIB_DIR}/libhts.a

Expand Down
7 changes: 5 additions & 2 deletions src/vcfpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,7 @@ class BcfWriter
std::shared_ptr<bcf1_t> b = std::shared_ptr<bcf1_t>(bcf_init(), variant_close()); // variant
int ret;
bool isHeaderWritten = false;
kstring_t ks = {0, 0, NULL};

public:
/// header object initialized by initalHeader
Expand Down Expand Up @@ -1580,8 +1581,10 @@ class BcfWriter
if(!isHeaderWritten && !writeHeader()) throw std::runtime_error("could not write header\n");
std::vector<char> str(vcfline.begin(), vcfline.end());
str.push_back('\0'); // don't forget string has no \0;
kstring_t s = {vcfline.length(), vcfline.length(), &str[0]}; // kstring
ret = vcf_parse1(&s, header.hdr, b.get());
ks.s = &str[0];
ks.l = vcfline.length();
ks.m = vcfline.length();
ret = vcf_parse1(&ks, header.hdr, b.get());
if(ret < 0) hts_log_debug("the ret is %i ", ret);
if(ret < 0) throw std::runtime_error("error parsing: " + vcfline + "\n");
if(b->errcode == BCF_ERR_CTG_UNDEF)
Expand Down

0 comments on commit f942aaa

Please sign in to comment.