diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-10-25 04:43:08 +0300 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-10-25 17:00:55 +0100 |
commit | fcff4663dd5bd33eed931c7731fd133f49551b4b (patch) | |
tree | 82bd9e2982d3b48bf37358170b96c9f02e7d6347 /unix/main.c | |
parent | 8204db6831f3934df4091c2f450f08ffefa34bd1 (diff) |
unix: Allow -X heapsize= option take numbers with K & M suffixes.
For kilobytes and megabytes respectively.
Diffstat (limited to 'unix/main.c')
-rw-r--r-- | unix/main.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/unix/main.c b/unix/main.c index 3c0a87767..a8de9fdee 100644 --- a/unix/main.c +++ b/unix/main.c @@ -269,7 +269,14 @@ void pre_process_options(int argc, char **argv) { emit_opt = MP_EMIT_OPT_VIPER; #if MICROPY_ENABLE_GC } else if (strncmp(argv[a + 1], "heapsize=", sizeof("heapsize=") - 1) == 0) { - heap_size = strtol(argv[a + 1] + sizeof("heapsize=") - 1, NULL, 0); + char *end; + heap_size = strtol(argv[a + 1] + sizeof("heapsize=") - 1, &end, 0); + // Don't bring unneeded libc dependencies like tolower() + if ((*end | 0x20) == 'k') { + heap_size *= 1024; + } else if ((*end | 0x20) == 'm') { + heap_size *= 1024 * 1024; + } #endif } else { exit(usage(argv)); |