diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-24 22:42:28 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-24 22:42:28 +0000 |
commit | 41d02b654e5c844f85fbb79283eaebf35af60fbb (patch) | |
tree | 224166f307256d81c08564546634106f7a8b0435 /py/emitinlinethumb.c | |
parent | ceb87835fe24873cd8b2f7d1d3d88cb6144e33b8 (diff) | |
download | micropython-41d02b654e5c844f85fbb79283eaebf35af60fbb.tar.gz micropython-41d02b654e5c844f85fbb79283eaebf35af60fbb.zip |
py: Improve freeing of emitters in mp_compile.
There can be multiple emitters allocated during compile (eg byte code
and native).
Diffstat (limited to 'py/emitinlinethumb.c')
-rw-r--r-- | py/emitinlinethumb.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/py/emitinlinethumb.c b/py/emitinlinethumb.c index 9d5a4206a0..c35192210c 100644 --- a/py/emitinlinethumb.c +++ b/py/emitinlinethumb.c @@ -20,13 +20,13 @@ struct _emit_inline_asm_t { int pass; scope_t *scope; - int max_num_labels; + uint max_num_labels; qstr *label_lookup; asm_thumb_t *as; }; emit_inline_asm_t *emit_inline_thumb_new(uint max_num_labels) { - emit_inline_asm_t *emit = m_new(emit_inline_asm_t, 1); + emit_inline_asm_t *emit = m_new_obj(emit_inline_asm_t); emit->max_num_labels = max_num_labels; emit->label_lookup = m_new(qstr, max_num_labels); memset(emit->label_lookup, 0, emit->max_num_labels * sizeof(qstr)); @@ -34,6 +34,12 @@ emit_inline_asm_t *emit_inline_thumb_new(uint max_num_labels) { return emit; } +void emit_inline_thumb_free(emit_inline_asm_t *emit) { + m_del(qstr, emit->label_lookup, emit->max_num_labels); + asm_thumb_free(emit->as, false); + m_del_obj(emit_inline_asm_t, emit); +} + static void emit_inline_thumb_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, scope_t *scope) { emit->pass = pass; emit->scope = scope; |