From 583656a3537bc43a28c58111520143df04bf27f2 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Tue, 21 Apr 2020 19:19:05 -0700 Subject: feat: added skeleton of biological library --- sys/libbio/test.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 sys/libbio/test.c (limited to 'sys/libbio/test.c') diff --git a/sys/libbio/test.c b/sys/libbio/test.c new file mode 100644 index 0000000..00345c4 --- /dev/null +++ b/sys/libbio/test.c @@ -0,0 +1,60 @@ +#include +#include +#include + +// ----------------------------------------------------------------------- +// Arena allocator + +static mem·Arena* ARENA; + +static +void* +bio·alloc(ulong size) +{ + return mem·arenaalloc(ARENA, size); +} + +static +void* +bio·realloc(void *ptr, ulong size) +{ + void* new = mem·arenaalloc(ARENA, size); + memcpy(new, ptr, size); + + return new; +} + +static +void +bio·free(void *ptr) +{ + /* stub */ +} + +static mem·Allocator arena = {.alloc = &bio·alloc, .realloc = &bio·realloc, .free = &bio·free }; + +// ----------------------------------------------------------------------- +// Point of entry for testing + +void +init() +{ + ARENA = mem·newarena(mem·sys); +} + +int +main() +{ + init(); + + bio·Tree t; + Stream *fd; + + fd = io·open("/home/nolln/root/data/test/example.nwk", "r"); + printf("starting\n"); + t = bio·readnewick(fd, arena); + io·close(fd); + printf("ending\n"); + return 0; +} + -- cgit v1.2.1