summaryrefslogtreecommitdiffstatshomepage
path: root/esp8266
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-07-04 21:34:40 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-07-04 21:34:40 +0300
commita22b6ebff1cee6e2d623a85d9aa8f93dff1512b4 (patch)
treec634552e6df8181b956c2adfeaaf6979bc5eb97d /esp8266
parente07ef8f1a2564b75dc1e1147f00d966f25dcc367 (diff)
downloadmicropython-a22b6ebff1cee6e2d623a85d9aa8f93dff1512b4.tar.gz
micropython-a22b6ebff1cee6e2d623a85d9aa8f93dff1512b4.zip
esp8266/esp_mphal: call_dupterm_read: Use readinto() method.
It's memory fragmentation hazard to allocate 1-char string each time by calling read() method.
Diffstat (limited to 'esp8266')
-rw-r--r--esp8266/esp_mphal.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/esp8266/esp_mphal.c b/esp8266/esp_mphal.c
index 9f090a0973..7d33f89cbf 100644
--- a/esp8266/esp_mphal.c
+++ b/esp8266/esp_mphal.c
@@ -161,16 +161,16 @@ static int call_dupterm_read(void) {
nlr_buf_t nlr;
if (nlr_push(&nlr) == 0) {
- mp_obj_t read_m[3];
- mp_load_method(MP_STATE_PORT(term_obj), MP_QSTR_read, read_m);
- read_m[2] = MP_OBJ_NEW_SMALL_INT(1);
- mp_obj_t res = mp_call_method_n_kw(1, 0, read_m);
+ mp_obj_t readinto_m[3];
+ mp_load_method(MP_STATE_PORT(term_obj), MP_QSTR_readinto, readinto_m);
+ readinto_m[2] = MP_STATE_PORT(dupterm_arr_obj);
+ mp_obj_t res = mp_call_method_n_kw(1, 0, readinto_m);
if (res == mp_const_none) {
nlr_pop();
return -2;
}
mp_buffer_info_t bufinfo;
- mp_get_buffer_raise(res, &bufinfo, MP_BUFFER_READ);
+ mp_get_buffer_raise(MP_STATE_PORT(dupterm_arr_obj), &bufinfo, MP_BUFFER_READ);
if (bufinfo.len == 0) {
mp_uos_deactivate("dupterm: EOF received, deactivating\n", MP_OBJ_NULL);
nlr_pop();