summaryrefslogtreecommitdiffstatshomepage
path: root/py/objarray.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-01-29 00:21:41 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-01-29 00:21:41 +0200
commit7f11c794a53b78dc90d924b8c44e6d8165d5b4af (patch)
tree3e1e7c0f00bafdfdccdad16c643c3914c7c36edc /py/objarray.c
parent1801421f6d204dfae9453187e1f70e261b230a9e (diff)
downloadmicropython-7f11c794a53b78dc90d924b8c44e6d8165d5b4af.tar.gz
micropython-7f11c794a53b78dc90d924b8c44e6d8165d5b4af.zip
mp_obj_new_bytearray_by_ref(): Allow to create array by reference.
This is special feature for FFI.
Diffstat (limited to 'py/objarray.c')
-rw-r--r--py/objarray.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/py/objarray.c b/py/objarray.c
index 9911e89df9..42dbfcda05 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -271,6 +271,17 @@ mp_obj_t mp_obj_new_bytearray(uint n, void *items) {
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 */