From: Stefan Beller Date: Tue, 17 May 2016 03:22:47 GMT Subject: [PATCH 3/3] rev-parse: free all memory Message-ID: <20160517032247.25092-4-sbeller@google.com> In-Reply-To: <20160517032247.25092-1-sbeller@google.com> From: Stefan Beller Signed-off-by: Stefan Beller --- builtin/rev-parse.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index c961b74..3296d22 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -371,7 +371,7 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix) static const char * const flag_chars = "*=?!"; struct strbuf sb = STRBUF_INIT, parsed = STRBUF_INIT; - const char **usage = NULL; + const char **usage = NULL, **curr_usage; struct option *opts = NULL; int onb = 0, osz = 0, unb = 0, usz = 0; @@ -472,6 +472,16 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix) strbuf_addf(&parsed, " --"); sq_quote_argv(&parsed, argv, 0); puts(parsed.buf); + +#ifdef FREE_ALL_MEMORY + curr_usage = usage; + while (curr_usage) { + free(*curr_usage); + curr_usage++; + } + free(usage); +#endif + return 0; } -- 2.8.2.401.g9c0faef