diff options
Diffstat (limited to 'sys/libbio/test.c')
-rw-r--r-- | sys/libbio/test.c | 60 |
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; +} + |