summaryrefslogtreecommitdiffstatshomepage
path: root/unix/main.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-09-23 18:10:17 +0100
committerDamien George <damien.p.george@gmail.com>2014-09-25 15:49:26 +0100
commitb0261341d3706329ea58d8fc1a5ff9c788c9ccf7 (patch)
tree97aed92dcb6bcf516c258ea56d525f1ed7d4c50f /unix/main.c
parentac04a8a56a1591ddbaf6558b8eab9837a7d2f3cb (diff)
downloadmicropython-b0261341d3706329ea58d8fc1a5ff9c788c9ccf7.tar.gz
micropython-b0261341d3706329ea58d8fc1a5ff9c788c9ccf7.zip
py: For malloc and vstr functions, use size_t exclusively for int type.
It seems most sensible to use size_t for measuring "number of bytes" in malloc and vstr functions (since that's what size_t is for). We don't use mp_uint_t because malloc and vstr are not Micro Python specific.
Diffstat (limited to 'unix/main.c')
-rw-r--r--unix/main.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/unix/main.c b/unix/main.c
index f00bf3d33a..983afd2a30 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -54,9 +54,9 @@
#include "stackctrl.h"
// Command line options, with their defaults
-bool compile_only = false;
-uint emit_opt = MP_EMIT_OPT_NONE;
-uint mp_verbose_flag;
+STATIC bool compile_only = false;
+STATIC uint emit_opt = MP_EMIT_OPT_NONE;
+mp_uint_t mp_verbose_flag = 0;
#if MICROPY_ENABLE_GC
// Heap size of GC heap (if enabled)
@@ -222,8 +222,9 @@ int usage(char **argv) {
return 1;
}
+#if MICROPY_MEM_STATS
STATIC mp_obj_t mem_info(void) {
- printf("mem: total=%d, current=%d, peak=%d\n",
+ printf("mem: total=" UINT_FMT ", current=" UINT_FMT ", peak=" UINT_FMT "\n",
m_get_total_bytes_allocated(), m_get_current_bytes_allocated(), m_get_peak_bytes_allocated());
printf("stack: " UINT_FMT "\n", mp_stack_usage());
#if MICROPY_ENABLE_GC
@@ -232,6 +233,7 @@ STATIC mp_obj_t mem_info(void) {
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mem_info_obj, mem_info);
+#endif
STATIC mp_obj_t qstr_info(void) {
uint n_pool, n_qstr, n_str_data_bytes, n_total_bytes;
@@ -325,7 +327,9 @@ int main(int argc, char **argv) {
mp_obj_list_init(mp_sys_argv, 0);
+ #if MICROPY_MEM_STATS
mp_store_name(qstr_from_str("mem_info"), (mp_obj_t*)&mem_info_obj);
+ #endif
mp_store_name(qstr_from_str("qstr_info"), (mp_obj_t*)&qstr_info_obj);
// Here is some example code to create a class and instance of that class.