summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/modusocket.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-28 23:43:01 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-28 23:43:01 +0000
commit0d3cb6726ddc1bab9fdd11a0aaa259fb436da4b2 (patch)
tree7285c3f452efdfce8c0ecb302bbd0e2efcca0c15 /stmhal/modusocket.c
parent57aebe171459fd599f8d430c1ea1660ed307360c (diff)
downloadmicropython-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 'stmhal/modusocket.c')
-rw-r--r--stmhal/modusocket.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/stmhal/modusocket.c b/stmhal/modusocket.c
index b52a9c8e88..a2ec08f59e 100644
--- a/stmhal/modusocket.c
+++ b/stmhal/modusocket.c
@@ -217,7 +217,6 @@ STATIC mp_obj_t socket_recv(mp_obj_t self_in, mp_obj_t len_in) {
return mp_const_empty_bytes;
}
vstr.len = ret;
- vstr.buf[vstr.len] = '\0';
return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_recv_obj, socket_recv);
@@ -269,7 +268,6 @@ STATIC mp_obj_t socket_recvfrom(mp_obj_t self_in, mp_obj_t len_in) {
tuple[0] = mp_const_empty_bytes;
} else {
vstr.len = ret;
- vstr.buf[vstr.len] = '\0';
tuple[0] = mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);
}
tuple[1] = mod_network_format_inet_addr(ip, port);