diff options
author | Damien <damien.p.george@gmail.com> | 2013-12-29 19:33:23 +0000 |
---|---|---|
committer | Damien <damien.p.george@gmail.com> | 2013-12-29 19:33:23 +0000 |
commit | 732407f1bf12364375162e8fb73816532a5d139c (patch) | |
tree | bf795d7bab01d6d603eec761affac7091be9606a /py/qstr.c | |
parent | a1c8e5737cebba08909104d47c1dfd16ef80e6a1 (diff) | |
download | micropython-732407f1bf12364375162e8fb73816532a5d139c.tar.gz micropython-732407f1bf12364375162e8fb73816532a5d139c.zip |
Change memory allocation API to require size for free and realloc.
Diffstat (limited to 'py/qstr.c')
-rw-r--r-- | py/qstr.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -16,8 +16,8 @@ void qstr_init(void) { static qstr qstr_add(const char *str) { if (qstrs_len >= qstrs_alloc) { + qstrs = m_renew(const char*, qstrs, qstrs_alloc, qstrs_alloc * 2); qstrs_alloc *= 2; - qstrs = m_renew(const char*, qstrs, qstrs_alloc); } qstrs[qstrs_len++] = str; return qstrs_len - 1; @@ -32,10 +32,10 @@ qstr qstr_from_str_static(const char *str) { return qstr_add(str); } -qstr qstr_from_str_take(char *str) { +qstr qstr_from_str_take(char *str, int alloc_len) { for (int i = 0; i < qstrs_len; i++) { if (strcmp(qstrs[i], str) == 0) { - m_free(str); + m_del(char, str, alloc_len); return i; } } |