diff options
author | Aki <please@ignore.pl> | 2021-03-05 00:40:27 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2021-03-05 00:40:27 +0100 |
commit | 2906145eec3c752f6c197c39611984aa91ab5a6e (patch) | |
tree | 5c48812e60d34837e343748ea39c03c9bc38e934 | |
parent | f1e2c3be1e87b716e716372330dd32a1b628144f (diff) | |
download | plop-2906145eec3c752f6c197c39611984aa91ab5a6e.zip plop-2906145eec3c752f6c197c39611984aa91ab5a6e.tar.gz plop-2906145eec3c752f6c197c39611984aa91ab5a6e.tar.bz2 |
Added output buffer growth
-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); |