diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2015-11-21 15:48:09 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-11-21 15:48:09 +0100 |
commit | d585073d582d82fae80781dc23176b1ef59527a9 (patch) | |
tree | c5239a1dd8e64450aa8ac412edd94fe5c31f5095 /rts/RtsFlags.c | |
parent | 7f77e4e9b301493db0782cf2d129cf62dbcd5af6 (diff) | |
download | haskell-d585073d582d82fae80781dc23176b1ef59527a9.tar.gz |
RtsFlags: Fix const warning
Reviewers: austin
Reviewed By: austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1509
Diffstat (limited to 'rts/RtsFlags.c')
-rw-r--r-- | rts/RtsFlags.c | 9 |
1 files changed, 8 insertions, 1 deletions
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 |