Commit eec88ee0 authored by thomie's avatar thomie
Browse files

RTS: simplify read_heap_profiling_flag

Since 535896e5, "args" is not mutated
anymore, so we don't need to create a temporary copy.

Reviewed by: bgamari

Differential Revision: https://phabricator.haskell.org/D2264
parent 961ed26b
......@@ -1588,15 +1588,10 @@ 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_in)
static rtsBool read_heap_profiling_flag(const char *arg)
{
// 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':
......@@ -1703,7 +1698,6 @@ static rtsBool read_heap_profiling_flag(const char *arg_in)
error = rtsTrue;
}
free(arg);
return error;
}
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment