diff options
author | Damien George <damien.p.george@gmail.com> | 2015-01-28 23:43:01 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-01-28 23:43:01 +0000 |
commit | 0d3cb6726ddc1bab9fdd11a0aaa259fb436da4b2 (patch) | |
tree | 7285c3f452efdfce8c0ecb302bbd0e2efcca0c15 /lib/mp-readline | |
parent | 57aebe171459fd599f8d430c1ea1660ed307360c (diff) | |
download | micropython-0d3cb6726ddc1bab9fdd11a0aaa259fb436da4b2.tar.gz micropython-0d3cb6726ddc1bab9fdd11a0aaa259fb436da4b2.zip |
py: Change vstr so that it doesn't null terminate buffer by default.
This cleans up vstr so that it's a pure "variable buffer", and the user
can decide whether they need to add a terminating null byte. In most
places where vstr is used, the vstr did not need to be null terminated
and so this patch saves code size, a tiny bit of RAM, and makes vstr
usage more efficient. When null termination is needed it must be
done explicitly using vstr_null_terminate.
Diffstat (limited to 'lib/mp-readline')
-rw-r--r-- | lib/mp-readline/readline.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/mp-readline/readline.c b/lib/mp-readline/readline.c index 767d509c7e..0303ff36d5 100644 --- a/lib/mp-readline/readline.c +++ b/lib/mp-readline/readline.c @@ -111,6 +111,7 @@ int readline_process_char(int c) { if (rl.line->len > rl.orig_line_len && (MP_STATE_PORT(readline_hist)[0] == NULL || strcmp(MP_STATE_PORT(readline_hist)[0], rl.line->buf + rl.orig_line_len) != 0)) { // a line which is not empty and different from the last one // so update the history + vstr_null_terminate(rl.line); char *most_recent_hist = str_dup_maybe(rl.line->buf + rl.orig_line_len); if (most_recent_hist != NULL) { for (int i = READLINE_HIST_SIZE - 1; i > 0; i--) { |