From 62f04ff585edd4f932f18ecad109f1d0213973a6 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Thu, 22 Apr 2021 14:08:40 -0700 Subject: chore(refactor): libraries to define explicit interfaces --- include/libbio.h | 4 ++-- include/libn.h | 17 ++++------------- 2 files changed, 6 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/libbio.h b/include/libbio.h index 7b28a55..558c163 100644 --- a/include/libbio.h +++ b/include/libbio.h @@ -63,8 +63,8 @@ typedef struct bio·Seq char *q; } bio·Seq; -bio·SeqReader *bio·open(io·Reader io, void *rdr, mem·Allocator mem, void *heap); -error bio·close(bio·SeqReader *rdr); +bio·SeqReader *bio·openseq(io·Reader io, void *rdr, mem·Allocator mem, void *heap); +error bio·closeseq(bio·SeqReader *rdr); error bio·readfasta(bio·SeqReader *rdr, bio·Seq *seq); error bio·readfastq(bio·SeqReader *rdr, bio·Seq *seq); diff --git a/include/libn.h b/include/libn.h index 30b4c87..2b8dc4c 100644 --- a/include/libn.h +++ b/include/libn.h @@ -51,32 +51,23 @@ typedef struct bufHdr void* bufgrow(void*, vlong, vlong); void _bufpop(void*, int, vlong); -// ----------------------------------------------------------------------------- -// interfaces -// TODO(nnoll): Think about this idea -/* -typedef struct Iface { - void* impl; - byte fcn[]; -} Iface; -*/ // ----------------------------------------------------------------------------- // memory allocation // TODO(nnoll): Allow for nil iterfaces? /* allocator interface */ typedef struct mem·Allocator { - void *(*alloc)(void *iface, uint n, ulong size); - void (*free)(void *iface, void *ptr); + void *(*alloc)(void *heap, uint n, ulong size); + void (*free)(void *heap, void *ptr); } mem·Allocator; -extern mem·Allocator mem·System; +extern mem·Allocator sys·Memory; typedef struct mem·Reallocator { void *(*alloc)(void *iface, uint n, ulong size); void *(*realloc)(void *iface, void *ptr, uint n, ulong size); void (*free)(void *iface, void *ptr); } mem·Reallocator; -extern mem·Reallocator mem·FullSystem; +extern mem·Reallocator sys·Relocator; /* simple memory arena */ typedef struct mem·Arena mem·Arena; -- cgit v1.2.1