diff options
| author | Damien George <damien.p.george@gmail.com> | 2014-04-13 12:52:39 +0100 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2014-04-13 12:52:39 +0100 |
| commit | 640e7e4779d5d6b5e53fa305e5fe824da7783090 (patch) | |
| tree | c299b3caf77aca8923a6fdb5554dd5a27ffc4c4e /py/objlist.c | |
| parent | f95c68e53638aa363797595b0d618bbe08c56bb3 (diff) | |
| parent | 4165cd1c0cfc4eabf446be504787090be84a421b (diff) | |
Merge pull request #476 from pfalcon/static-sys
Convert sys module to static allocation
Diffstat (limited to 'py/objlist.c')
| -rw-r--r-- | py/objlist.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/py/objlist.c b/py/objlist.c index 7c2986733..fa7d2bc1c 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -8,13 +8,7 @@ #include "obj.h" #include "runtime0.h" #include "runtime.h" - -typedef struct _mp_obj_list_t { - mp_obj_base_t base; - machine_uint_t alloc; - machine_uint_t len; - mp_obj_t *items; -} mp_obj_list_t; +#include "objlist.h" STATIC mp_obj_t mp_obj_new_list_iterator(mp_obj_list_t *list, int cur); STATIC mp_obj_list_t *list_new(uint n); @@ -371,12 +365,16 @@ const mp_obj_type_t mp_type_list = { .locals_dict = (mp_obj_t)&list_locals_dict, }; -STATIC mp_obj_list_t *list_new(uint n) { - mp_obj_list_t *o = m_new_obj(mp_obj_list_t); +void mp_obj_list_init(mp_obj_list_t *o, uint n) { o->base.type = &mp_type_list; o->alloc = n < LIST_MIN_ALLOC ? LIST_MIN_ALLOC : n; o->len = n; o->items = m_new(mp_obj_t, o->alloc); +} + +STATIC mp_obj_list_t *list_new(uint n) { + mp_obj_list_t *o = m_new_obj(mp_obj_list_t); + mp_obj_list_init(o, n); return o; } |
