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. --- py/emitcpy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'py/emitcpy.c') diff --git a/py/emitcpy.c b/py/emitcpy.c index 924a5566d..09a0e006f 100644 --- a/py/emitcpy.c +++ b/py/emitcpy.c @@ -800,10 +800,10 @@ STATIC void emit_cpy_end_except_handler(emit_t *emit) { emit_cpy_adjust_stack_size(emit, -5); // stack adjust } -STATIC void emit_cpy_load_const_verbatim_str(emit_t *emit, const char *str) { +STATIC void emit_cpy_load_const_verbatim_strn(emit_t *emit, const char *str, mp_uint_t len) { emit_pre(emit, 1, 3); if (emit->pass == MP_PASS_EMIT) { - printf("LOAD_CONST %s\n", str); + printf("LOAD_CONST %.*s\n", (int)len, str); } } @@ -912,7 +912,7 @@ const emit_method_table_t emit_cpython_method_table = { emit_cpy_end_except_handler, // emitcpy specific functions - emit_cpy_load_const_verbatim_str, + emit_cpy_load_const_verbatim_strn, emit_cpy_load_closure, emit_cpy_setup_loop, }; -- cgit v1.2.3