[PATCH 3/3] rev-parse: free all memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Stefan Beller <stefanbeller@xxxxxxxxx>

Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]