py: Use m_{new,renew,del} consistently.
This is so all memory requests go through the same interface.
diff --git a/py/lexerstr.c b/py/lexerstr.c
index cab3ed3..5481b10 100644
--- a/py/lexerstr.c
+++ b/py/lexerstr.c
@@ -43,7 +43,7 @@
STATIC void str_buf_free(mp_lexer_str_buf_t *sb) {
if (sb->free_len > 0) {
- m_free((char*)sb->src_beg, sb->free_len);
+ m_del(char, (char*)sb->src_beg, sb->free_len);
}
m_del_obj(mp_lexer_str_buf_t, sb);
}
diff --git a/py/objarray.c b/py/objarray.c
index 25d9dae..e2fee1f 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -116,7 +116,7 @@
o->typecode = typecode;
o->free = 0;
o->len = n;
- o->items = m_malloc(typecode_size * o->len);
+ o->items = m_new(byte, typecode_size * o->len);
return o;
}
#endif
@@ -298,7 +298,7 @@
int item_sz = mp_binary_get_size('@', self->typecode, NULL);
// TODO: alloc policy
self->free = 8;
- self->items = m_realloc(self->items, item_sz * self->len, item_sz * (self->len + self->free));
+ self->items = m_renew(byte, self->items, item_sz * self->len, item_sz * (self->len + self->free));
mp_seq_clear(self->items, self->len + 1, self->len + self->free, item_sz);
}
mp_binary_set_val_array(self->typecode, self->items, self->len++, arg);
@@ -324,7 +324,7 @@
// make sure we have enough room to extend
// TODO: alloc policy; at the moment we go conservative
if (self->free < len) {
- self->items = m_realloc(self->items, (self->len + self->free) * sz, (self->len + len) * sz);
+ self->items = m_renew(byte, self->items, (self->len + self->free) * sz, (self->len + len) * sz);
self->free = 0;
} else {
self->free -= len;
diff --git a/py/objexcept.c b/py/objexcept.c
index 8bd802e..987a54f 100644
--- a/py/objexcept.c
+++ b/py/objexcept.c
@@ -64,7 +64,7 @@
mp_int_t size = mp_obj_get_int(size_in);
void *buf = NULL;
if (size > 0) {
- buf = m_malloc(size);
+ buf = m_new(byte, size);
}
int old_size = mp_emergency_exception_buf_size;
@@ -78,7 +78,7 @@
MICROPY_END_ATOMIC_SECTION(atomic_state);
if (old_buf != NULL) {
- m_free(old_buf, old_size);
+ m_del(byte, old_buf, old_size);
}
return mp_const_none;
}
diff --git a/py/objint.c b/py/objint.c
index 4a4a21a..0fb2a38 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -137,7 +137,7 @@
print(env, "%s", str);
if (buf != stack_buf) {
- m_free(buf, buf_size);
+ m_del(char, buf, buf_size);
}
}
diff --git a/py/objtuple.c b/py/objtuple.c
index 55358a6..d575dec 100644
--- a/py/objtuple.c
+++ b/py/objtuple.c
@@ -95,7 +95,7 @@
}
mp_obj_t tuple = mp_obj_new_tuple(len, items);
- m_free(items, alloc);
+ m_del(mp_obj_t, items, alloc);
return tuple;
}
diff --git a/py/pfenv.c b/py/pfenv.c
index 09ca0ef..8bc42dc 100644
--- a/py/pfenv.c
+++ b/py/pfenv.c
@@ -308,7 +308,7 @@
}
if (buf != stack_buf) {
- m_free(buf, buf_size);
+ m_del(char, buf, buf_size);
}
return len;
}