aboutsummaryrefslogtreecommitdiff
path: root/sys/libbio/test.c
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-04-22 20:00:41 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-04-22 20:00:41 -0700
commit1a6c99600617f069d6d167fb3d33142a07fe0936 (patch)
treeea41789b66c0bb220b9f3703ddb7a3c9482ddbc9 /sys/libbio/test.c
parent7f1b6ff70b97e424ce73314809838c7cd94f3ae7 (diff)
fix: double free problem
Diffstat (limited to 'sys/libbio/test.c')
-rw-r--r--sys/libbio/test.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/libbio/test.c b/sys/libbio/test.c
index 3941290..fb79302 100644
--- a/sys/libbio/test.c
+++ b/sys/libbio/test.c
@@ -36,6 +36,7 @@ static mem·Allocator arena = {.alloc = &bio·alloc, .realloc = &bio·realloc, .
// -----------------------------------------------------------------------
// Read/writer
+/* Static reader thunk */
static Stream* INPUT;
static
@@ -52,8 +53,9 @@ unget(byte c)
return io·ungetbyte(INPUT, c);
}
-static io·Peeker peeker = {.get = &get, .unget = &unget};
+static io·Peeker rdr = {.get = &get, .unget = &unget};
+/* Static writer thunk */
static Stream* OUTPUT;
static
@@ -70,7 +72,7 @@ putstr(string s)
return io·putstring(OUTPUT, s);
}
-static io·Putter putter = {.put = &put, .putstr = &putstr};
+static io·Putter wtr = {.put = &put, .putstr = &putstr};
// -----------------------------------------------------------------------
// Point of entry for testing
@@ -96,13 +98,13 @@ main()
INPUT = fd[0];
OUTPUT = fd[1];
- printf("starting\n");
- t = bio·readnewick(peeker, arena);
- err = bio·writenewick(t, putter);
- printf("ending\n");
+ t = bio·readnewick(rdr, arena);
+ err = bio·writenewick(t, wtr);
io·flush(fd[1]);
io·close(fd[0]); io·close(fd[1]);
+
+ mem·freearena(ARENA);
return 0;
}