aboutsummaryrefslogtreecommitdiff
path: root/sys/libbio/test.c
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-04-21 19:19:05 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-04-21 19:19:05 -0700
commit583656a3537bc43a28c58111520143df04bf27f2 (patch)
tree8e75d98cea3d6af1d1b85d5c5b5e22ac5e0c4cde /sys/libbio/test.c
parente596ebd0c129913b7135210b23a50336b6f8556f (diff)
feat: added skeleton of biological library
Diffstat (limited to 'sys/libbio/test.c')
-rw-r--r--sys/libbio/test.c60
1 files changed, 60 insertions, 0 deletions
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 <u.h>
+#include <libn.h>
+#include <libbio.h>
+
+// -----------------------------------------------------------------------
+// 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;
+}
+