summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-03-05 00:40:27 +0100
committerAki <please@ignore.pl>2021-03-05 00:40:27 +0100
commit2906145eec3c752f6c197c39611984aa91ab5a6e (patch)
tree5c48812e60d34837e343748ea39c03c9bc38e934
parentf1e2c3be1e87b716e716372330dd32a1b628144f (diff)
downloadplop-2906145eec3c752f6c197c39611984aa91ab5a6e.zip
plop-2906145eec3c752f6c197c39611984aa91ab5a6e.tar.gz
plop-2906145eec3c752f6c197c39611984aa91ab5a6e.tar.bz2
Added output buffer growth
-rw-r--r--stream.c9
1 files 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);