Use PGM_P for PSTR pointers (#11977)

This commit is contained in:
Scott Lahteine
2018-09-30 23:44:33 -05:00
committed by GitHub
parent 4d5566a6b7
commit 11ac75edcb
39 changed files with 166 additions and 165 deletions

View File

@ -170,7 +170,7 @@ void GcodeSuite::dwell(millis_t time) {
// Placeholders for non-migrated codes
//
#if ENABLED(M100_FREE_MEMORY_WATCHER)
extern void M100_dump_routine(const char * const title, const char *start, const char *end);
extern void M100_dump_routine(PGM_P const title, const char *start, const char *end);
#endif
/**
@ -700,7 +700,7 @@ void GcodeSuite::process_next_command() {
SERIAL_ECHOLN(current_command);
#if ENABLED(M100_FREE_MEMORY_WATCHER)
SERIAL_ECHOPAIR("slot:", cmd_queue_index_r);
M100_dump_routine(" Command Queue:", (const char*)command_queue, (const char*)(command_queue + sizeof(command_queue)));
M100_dump_routine(PSTR(" Command Queue:"), (const char*)command_queue, (const char*)(command_queue + sizeof(command_queue)));
#endif
}
@ -714,14 +714,14 @@ void GcodeSuite::process_next_command() {
* Run a series of commands, bypassing the command queue to allow
* G-code "macros" to be called from within other G-code handlers.
*/
void GcodeSuite::process_subcommands_now_P(const char *pgcode) {
void GcodeSuite::process_subcommands_now_P(PGM_P pgcode) {
// Save the parser state
char * const saved_cmd = parser.command_ptr;
// Process individual commands in string
while (pgm_read_byte_near(pgcode)) {
// Break up string at '\n' delimiters
const char *delim = strchr_P(pgcode, '\n');
PGM_P const delim = strchr_P(pgcode, '\n');
size_t len = delim ? delim - pgcode : strlen_P(pgcode);
char cmd[len + 1];
strncpy_P(cmd, pgcode, len);