From 0d3cb6726ddc1bab9fdd11a0aaa259fb436da4b2 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 28 Jan 2015 23:43:01 +0000 Subject: 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. --- lib/mp-readline/readline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/mp-readline/readline.c b/lib/mp-readline/readline.c index 767d509c7..0303ff36d 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--) { -- cgit v1.2.3