diff options
| -rw-r--r-- | includes/rts/Flags.h | 14 | ||||
| -rw-r--r-- | rts/ProfHeap.c | 4 | ||||
| -rw-r--r-- | rts/ProfHeap.h | 2 | ||||
| -rw-r--r-- | rts/RtsFlags.c | 9 |
4 files changed, 18 insertions, 11 deletions
diff --git a/includes/rts/Flags.h b/includes/rts/Flags.h index 878e0f111a..9321b4d160 100644 --- a/includes/rts/Flags.h +++ b/includes/rts/Flags.h @@ -131,13 +131,13 @@ typedef struct _PROFILING_FLAGS { nat ccsLength; - char* modSelector; - char* descrSelector; - char* typeSelector; - char* ccSelector; - char* ccsSelector; - char* retainerSelector; - char* bioSelector; + const char* modSelector; + const char* descrSelector; + const char* typeSelector; + const char* ccSelector; + const char* ccsSelector; + const char* retainerSelector; + const char* bioSelector; } PROFILING_FLAGS; diff --git a/rts/ProfHeap.c b/rts/ProfHeap.c index bfb8aaae2d..43bd7b4225 100644 --- a/rts/ProfHeap.c +++ b/rts/ProfHeap.c @@ -549,9 +549,9 @@ fprint_ccs(FILE *fp, CostCentreStack *ccs, nat max_length) } rtsBool -strMatchesSelector( char* str, char* sel ) +strMatchesSelector( const char* str, const char* sel ) { - char* p; + const char* p; // debugBelch("str_matches_selector %s %s\n", str, sel); while (1) { // Compare str against wherever we've got to in sel. diff --git a/rts/ProfHeap.h b/rts/ProfHeap.h index b3bed903b5..e29a9f6974 100644 --- a/rts/ProfHeap.h +++ b/rts/ProfHeap.h @@ -14,7 +14,7 @@ void heapCensus (Time t); nat initHeapProfiling (void); void endHeapProfiling (void); -rtsBool strMatchesSelector (char* str, char* sel); +rtsBool strMatchesSelector (const char* str, const char* sel); #include "EndPrivate.h" diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c index e3051287e6..94572792de 100644 --- a/rts/RtsFlags.c +++ b/rts/RtsFlags.c @@ -1531,9 +1531,15 @@ static void read_debug_flags(const char* arg) #ifdef PROFILING // Parse a "-h" flag, returning whether the parse resulted in an error. -static rtsBool read_heap_profiling_flag(const char *arg) +static rtsBool read_heap_profiling_flag(const char *arg_in) { // Already parsed "-h" + + // For historical reasons the parser here mutates the arguments. + // However, for sanity we want to guarantee const-correctness and parsing + // really ought to be an immutable operation. To avoid rewriting the parser + // we just operate on a temporary copy of the argument. + char *arg = strdup(arg_in); rtsBool error = rtsFalse; switch (arg[2]) { case '\0': @@ -1638,6 +1644,7 @@ static rtsBool read_heap_profiling_flag(const char *arg) error = rtsTrue; } + free(arg); return error; } #endif |
