From 622ec3cadbda926e02af594d2ff7e89d33833b36 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Sat, 25 Apr 2020 12:43:11 -0700 Subject: chore: prepare for refactoring to allow for fastq --- sys/libbio/io/fasta.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'sys/libbio/io/fasta.c') diff --git a/sys/libbio/io/fasta.c b/sys/libbio/io/fasta.c index 891e222..5e659ab 100644 --- a/sys/libbio/io/fasta.c +++ b/sys/libbio/io/fasta.c @@ -132,15 +132,18 @@ fill(bio·FastaReader *rdr) return 0; } +// ----------------------------------------------------------------------- +// Fasta files + bio·FastaReader* -bio·newfastareader(io·Reader stream, void *s, mem·Allocator heap, void *h) +bio·openfasta(io·Reader file, void *f, mem·Allocator heap, void *h) { error err; bio·FastaReader *rdr; rdr = heap.alloc(h, 1, sizeof(bio·FastaReader)); - rdr->file = stream; - rdr->f = s; + rdr->file = file; + rdr->f = f; rdr->eof = 0; rdr->seq = heap.alloc(h, 1, sizeof(*rdr->seq) + INIT_NM_SIZE + INIT_SQ_SIZE); @@ -236,3 +239,22 @@ SUCCESS: return 0; } + +error +bio·closefasta(bio·FastaReader *rdr) +{ + mem·Allocator heap; + void *h; + + + heap = rdr->seq->heap; + h = rdr->seq->h; + + heap.free(h, rdr->seq); + heap.free(h, rdr); + + return 0; +} + +// ----------------------------------------------------------------------- +// Fastq files -- cgit v1.2.1