From 2906145eec3c752f6c197c39611984aa91ab5a6e Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 5 Mar 2021 00:40:27 +0100 Subject: Added output buffer growth --- stream.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stream.c b/stream.c index 2fec796..017c031 100644 --- a/stream.c +++ b/stream.c @@ -315,15 +315,16 @@ int stream_write(lua_State * L) const char * data = lua_tolstring(L, i, &data_length); const int free_space = s->out.allocated - s->out.length; + while (free_space < (int) data_length) + { + grow(L, &s->out); + } + if (free_space >= (int) data_length) { memcpy(&s->out.data[s->out.length], data, data_length); s->out.length += (int) data_length; } - else - { - // TODO: grow - } } lua_pop(L, n); -- cgit v1.1