Skip to content

Commit

Permalink
Move debug constant strings to PROGMEM (#3478)
Browse files Browse the repository at this point in the history
UMM debugging strings are normally placed in RODATA, which uses up scarse
memory.  Move them to PROGMEM and use macros to replace printf with a
version that can handle ROM strings.
  • Loading branch information
earlephilhower authored and igrr committed Aug 7, 2017
1 parent ff4bb73 commit 4bed115
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cores/esp8266/umm_malloc/umm_malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@

#include <stdio.h>
#include <string.h>
#include <pgmspace.h>

#include "umm_malloc.h"

Expand All @@ -512,6 +513,9 @@
# define DBG_LOG_LEVEL DBG_LOG_LEVEL
#endif

// Macro to place constant strings into PROGMEM and print them properly
#define printf(fmt, ...) do { static const char fstr[] PROGMEM = fmt; char rstr[sizeof(fmt)]; for (size_t i=0; i<sizeof(rstr); i++) rstr[i] = fstr[i]; printf(rstr, ##__VA_ARGS__); } while (0)

/* -- dbglog {{{ */

/* ----------------------------------------------------------------------------
Expand Down

0 comments on commit 4bed115

Please sign in to comment.