diff options
author | Damien George <damien.p.george@gmail.com> | 2014-02-10 22:51:35 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-02-10 22:51:35 +0000 |
commit | f1081f400b3dd072fd46704d93557bd40ae617e5 (patch) | |
tree | 418dbb67431fe21ce9ca8578c3ec271a52ceded5 /py | |
parent | ed378cd12f05c78c735dffe1c0a6b3cb4337e67d (diff) | |
parent | 724026ab402a13a2344ac6679a665394777ff0fa (diff) | |
download | micropython-f1081f400b3dd072fd46704d93557bd40ae617e5.tar.gz micropython-f1081f400b3dd072fd46704d93557bd40ae617e5.zip |
Merge branch 'master' of github.com:micropython/micropython
Diffstat (limited to 'py')
-rw-r--r-- | py/compile.c | 2 | ||||
-rw-r--r-- | py/grammar.h | 4 | ||||
-rw-r--r-- | py/malloc.c | 17 |
3 files changed, 7 insertions, 16 deletions
diff --git a/py/compile.c b/py/compile.c index 1abe08c432..521c5290cd 100644 --- a/py/compile.c +++ b/py/compile.c @@ -2764,7 +2764,7 @@ void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) { apply_to_single_or_list(comp, pns->nodes[1], PN_typedargslist, compile_scope_func_param); } - assert(MP_PARSE_NODE_IS_NULL(pns->nodes[2])); // 2 is something... + // pns->nodes[2] is return/whole function annotation compile_node(comp, pns->nodes[3]); // 3 is function body // emit return if it wasn't the last opcode diff --git a/py/grammar.h b/py/grammar.h index c58ad9e069..4823ccb12b 100644 --- a/py/grammar.h +++ b/py/grammar.h @@ -33,8 +33,8 @@ DEF_RULE(decorator, nc, and(4), tok(DEL_AT), rule(dotted_name), opt_rule(trailer DEF_RULE(decorators, nc, one_or_more, rule(decorator)) DEF_RULE(decorated, c(decorated), and(2), rule(decorators), rule(decorated_body)) DEF_RULE(decorated_body, nc, or(2), rule(classdef), rule(funcdef)) -DEF_RULE(funcdef, c(funcdef), and(8), tok(KW_DEF), tok(NAME), tok(DEL_PAREN_OPEN), opt_rule(typedargslist), tok(DEL_PAREN_CLOSE), opt_rule(funcdef_2), tok(DEL_COLON), rule(suite)) -DEF_RULE(funcdef_2, nc, and(2), tok(DEL_MINUS_MORE), rule(test)) +DEF_RULE(funcdef, c(funcdef), and(8), tok(KW_DEF), tok(NAME), tok(DEL_PAREN_OPEN), opt_rule(typedargslist), tok(DEL_PAREN_CLOSE), opt_rule(funcdefrettype), tok(DEL_COLON), rule(suite)) +DEF_RULE(funcdefrettype, nc, and(2), tok(DEL_MINUS_MORE), rule(test)) // TODO typedargslist lets through more than is allowed DEF_RULE(typedargslist, nc, list_with_end, rule(typedargslist_item), tok(DEL_COMMA)) DEF_RULE(typedargslist_item, nc, or(3), rule(typedargslist_name), rule(typedargslist_star), rule(typedargslist_dbl_star)) diff --git a/py/malloc.c b/py/malloc.c index 59570243f0..c87d91c0a0 100644 --- a/py/malloc.c +++ b/py/malloc.c @@ -1,5 +1,6 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "misc.h" #include "mpconfig.h" @@ -37,20 +38,10 @@ void *m_malloc(int num_bytes) { } void *m_malloc0(int num_bytes) { - if (num_bytes == 0) { - return NULL; - } - void *ptr = calloc(1, num_bytes); - if (ptr == NULL) { - printf("could not allocate memory, allocating %d bytes\n", num_bytes); - return NULL; + void *ptr = m_malloc(num_bytes); + if (ptr != NULL) { + memset(ptr, 0, num_bytes); } -#if MICROPY_MEM_STATS - total_bytes_allocated += num_bytes; - current_bytes_allocated += num_bytes; - UPDATE_PEAK(); -#endif - DEBUG_printf("malloc0 %d : %p\n", num_bytes, ptr); return ptr; } |