diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-01-13 23:15:23 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-01-13 23:31:06 +0200 |
commit | 5d2499c63813566b1e35067f6faff3046c7f9d0a (patch) | |
tree | 087fb823543cf4fd2c0bd27c6c373c3035e2e54f /py/lexer.c | |
parent | ca318bba0d97c66d8fb14a089d8fa269a0e1b424 (diff) | |
download | micropython-5d2499c63813566b1e35067f6faff3046c7f9d0a.tar.gz micropython-5d2499c63813566b1e35067f6faff3046c7f9d0a.zip |
Add "buffer management" and "shrink" API calls to vstr.
vstr is initially intended to deal with arbitrary-length strings. By
providing a bit lower-level API calls, it will be also useful to deal
with arbitrary-length I/O buffers (the difference from strings is that
buffers are filled from "outside", via I/O).
Another issue, especially aggravated by I/O buffer use, is alloc size
vs actual size length. If allocated 1Mb for buffer, but actually
read 1 byte, we don't want to keep rest of 1Mb be locked by this I/O
result, but rather return it to heap ASAP ("shrink" buffer before passing
it to qstr_from_str_take()).
Diffstat (limited to 'py/lexer.c')
-rw-r--r-- | py/lexer.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/py/lexer.c b/py/lexer.c index f7f9c631f3..da8967b163 100644 --- a/py/lexer.c +++ b/py/lexer.c @@ -614,7 +614,7 @@ mp_lexer_t *mp_lexer_new(const char *src_name, void *stream_data, mp_lexer_strea lex->num_indent_level = 1; lex->indent_level = m_new(uint16_t, lex->alloc_indent_level); lex->indent_level[0] = 0; - vstr_init(&lex->vstr); + vstr_init(&lex->vstr, 32); // preload characters lex->chr0 = stream_next_char(stream_data); |