mp_obj_new_bytearray_by_ref(): Allow to create array by reference.
This is special feature for FFI.
diff --git a/py/objarray.c b/py/objarray.c
index 9911e89..42dbfcd 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -271,6 +271,17 @@
return o;
}
+// Create bytearray which references specified memory area
+mp_obj_t mp_obj_new_bytearray_by_ref(uint n, void *items) {
+ mp_obj_array_t *o = m_new_obj(mp_obj_array_t);
+ o->base.type = &array_type;
+ o->typecode = BYTEARRAY_TYPECODE;
+ o->free = 0;
+ o->len = n;
+ o->items = items;
+ return o;
+}
+
/******************************************************************************/
/* array iterator */