summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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);