summaryrefslogtreecommitdiffstats
path: root/stream.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-03-12 02:50:08 -0700
committerKaz Kylheku <kaz@kylheku.com>2012-03-12 02:50:08 -0700
commit2eb1be2b7f8fc254e4f5556ada63279dff60b46b (patch)
tree9b40441fd4bd2235ac10ffe4fb4a23c803e6c879 /stream.c
parent684c64c4107a578657e55bbcae8e74873775b1f5 (diff)
downloadtxr-2eb1be2b7f8fc254e4f5556ada63279dff60b46b.tar.gz
txr-2eb1be2b7f8fc254e4f5556ada63279dff60b46b.tar.bz2
txr-2eb1be2b7f8fc254e4f5556ada63279dff60b46b.zip
Plugging memory leak.
* stream.c (byte_in_stream_destroy): New function. (byte_in_ops): Use new function instead of noop stub.
Diffstat (limited to 'stream.c')
-rw-r--r--stream.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/stream.c b/stream.c
index 62cd85ae..dc24b304 100644
--- a/stream.c
+++ b/stream.c
@@ -401,6 +401,18 @@ struct byte_input {
size_t index;
};
+static void byte_in_stream_destroy(val stream)
+{
+ struct byte_input *bi = (struct byte_input *) stream->co.handle;
+
+ if (bi) {
+ free(bi->buf);
+ bi->buf = 0;
+ free(bi);
+ stream->co.handle = 0;
+ }
+}
+
static val byte_in_get_byte(val stream)
{
struct byte_input *bi = (struct byte_input *) stream->co.handle;
@@ -413,7 +425,7 @@ static val byte_in_get_byte(val stream)
static struct strm_ops byte_in_ops = {
{ cobj_equal_op,
cobj_print_op,
- cobj_destroy_stub_op,
+ byte_in_stream_destroy,
cobj_mark_op,
cobj_hash_op },
0,