diff options
author | Damien George <damien.p.george@gmail.com> | 2017-03-23 16:17:40 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-03-23 16:17:40 +1100 |
commit | c88cfe165b0ab39c5d9392fb02dd12f22be1a28d (patch) | |
tree | df03d503b13f11fde8730956f4adf883ce153496 /py/obj.c | |
parent | 3f3df435014cc835ce9357e15ddb8996c5866f43 (diff) |
py: Use size_t as len argument and return type of mp_get_index.
These values are used to compute memory addresses and so size_t is the
more appropriate type to use.
Diffstat (limited to 'py/obj.c')
-rw-r--r-- | py/obj.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -351,7 +351,7 @@ void mp_obj_get_array_fixed_n(mp_obj_t o, mp_uint_t len, mp_obj_t **items) { } // is_slice determines whether the index is a slice index -mp_uint_t mp_get_index(const mp_obj_type_t *type, mp_uint_t len, mp_obj_t index, bool is_slice) { +size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool is_slice) { mp_int_t i; if (MP_OBJ_IS_SMALL_INT(index)) { i = MP_OBJ_SMALL_INT_VALUE(index); @@ -384,7 +384,9 @@ mp_uint_t mp_get_index(const mp_obj_type_t *type, mp_uint_t len, mp_obj_t index, } } } - return i; + + // By this point 0 <= i <= len and so fits in a size_t + return (size_t)i; } mp_obj_t mp_obj_id(mp_obj_t o_in) { |