From 507d25e2cdac7489ca8706f6582e271fd1689816 Mon Sep 17 00:00:00 2001 From: Leo C Date: Mon, 1 Sep 2014 17:06:58 +0200 Subject: process_macros: reduce heap usage and fragmentation --- avr/debug.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'avr/debug.c') diff --git a/avr/debug.c b/avr/debug.c index 16df702..47b11b0 100644 --- a/avr/debug.c +++ b/avr/debug.c @@ -23,7 +23,7 @@ static uint8_t ram_read_byte(const uint8_t *p) return *p; } -void dump_mem(const uint8_t *startaddr, int len, +void dump_mem(const uint8_t *startaddr, int len, uint8_t (*readfkt)(const uint8_t *), char *title) { uint8_t buf[16]; @@ -33,12 +33,12 @@ void dump_mem(const uint8_t *startaddr, int len, const uint8_t *addr = (uint8_t *) ((size_t) startaddr & ~0x0f); len += pre; uint8_t i; - + if (title && *title) { printf_P(PSTR("%s\n"),title); indent = " "; } - + while (len) { if (len < 16) llen = len; @@ -100,7 +100,7 @@ command_ret_t do_dump_mem(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg // static const uint8_t *addr; // static uint16_t length = 128; uint8_t (*readhow)(const uint8_t *); - + (void) cmdtp; (void) flag; if (argc < 2) @@ -108,7 +108,7 @@ command_ret_t do_dump_mem(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg const uint8_t *addr; uint16_t length = 128; - + if (strchr(argv[0],'r') != NULL) readhow = ram_read_byte; else if (strchr(argv[0],'e') != NULL) @@ -182,7 +182,7 @@ command_ret_t do_eep_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[ /*------------------------------------------------------------------------------*/ -#if 0 +#if 1 struct __freelist { size_t sz; @@ -201,6 +201,8 @@ printfreelist(const char * title) int i; unsigned int freesum = 0; +/* TODO: printf_P */ + if (!__flp) { printf("%s no free list\n", title ? title : ""); } else { @@ -215,7 +217,7 @@ printfreelist(const char * title) freesum += fp1->sz; } } - + freesum += (size_t) STACK_POINTER() - __malloc_margin - (size_t) __brkval; printf("SP: %04x, __brkval: %04x, Total free: %04u\n", -- cgit v1.2.3