From 2eb1be2b7f8fc254e4f5556ada63279dff60b46b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 12 Mar 2012 02:50:08 -0700 Subject: Plugging memory leak. * stream.c (byte_in_stream_destroy): New function. (byte_in_ops): Use new function instead of noop stub. --- ChangeLog | 7 +++++++ stream.c | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2f25d548..f93d98af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-03-12 Kaz Kylheku + + Plugging memory leak. + + * stream.c (byte_in_stream_destroy): New function. + (byte_in_ops): Use new function instead of noop stub. + 2012-03-04 Kaz Kylheku * txr.vim: Update. Adding remq, remql, remqual, regsub, *stddebug* 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, -- cgit v1.2.3