extmod/modbluetooth: Free temp arrays in gatts register services.
This helps to reduce memory fragmentation, by freeing the heap data as soon as it is not needed. It also helps the compiler keeps a reference to the beginning of both arrays, which need to be traceable by the GC (otherwise some compilers may optimise this reference to something else). Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
d53a6d58b0
commit
2b888aa2f3
@ -619,6 +619,11 @@ STATIC mp_obj_t bluetooth_ble_gatts_register_services(mp_obj_t self_in, mp_obj_t
|
||||
}
|
||||
result->items[i] = MP_OBJ_FROM_PTR(service_handles);
|
||||
}
|
||||
|
||||
// Free temporary arrays.
|
||||
m_del(uint16_t *, handles, len);
|
||||
m_del(size_t, num_handles, len);
|
||||
|
||||
return MP_OBJ_FROM_PTR(result);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bluetooth_ble_gatts_register_services_obj, bluetooth_ble_gatts_register_services);
|
||||
|
Loading…
Reference in New Issue
Block a user