diff options
-rw-r--r-- | stream.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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); |