extmod/moduos_dupterm: Reserve buffer bytearray object for dupterm.
Allocating it for each read/write operation is a memory fragmentation hazard.
This commit is contained in:
parent
d83177b248
commit
426112ce88
|
@ -69,9 +69,12 @@ STATIC mp_obj_t mp_uos_dupterm(mp_uint_t n_args, const mp_obj_t *args) {
|
|||
}
|
||||
} else {
|
||||
if (args[0] == mp_const_none) {
|
||||
MP_STATE_PORT(term_obj) = NULL;
|
||||
MP_STATE_PORT(term_obj) = MP_OBJ_NULL;
|
||||
} else {
|
||||
MP_STATE_PORT(term_obj) = args[0];
|
||||
if (MP_STATE_PORT(dupterm_arr_obj) == MP_OBJ_NULL) {
|
||||
MP_STATE_PORT(dupterm_arr_obj) = mp_obj_new_bytearray(1, "");
|
||||
}
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
|
|
@ -143,6 +143,7 @@ typedef struct _mp_state_vm_t {
|
|||
|
||||
#if MICROPY_PY_OS_DUPTERM
|
||||
mp_obj_t term_obj;
|
||||
mp_obj_t dupterm_arr_obj;
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_LWIP_SLIP
|
||||
|
|
Loading…
Reference in New Issue