git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] git-rev-parse: use leaky().

From
Pierre Habouzit <madcoder@debian.org>
Date
Jun 24, 2008, 20:14 UTC
Message-ID
<1214338474-16822-3-git-send-email-madcoder@debian.org>
In-Reply-To
<1214338474-16822-2-git-send-email-madcoder@debian.org>

Mark the mallocs that cmd_parseopt never frees as leaky so that nobody loses time trying to fix them.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
 builtin-rev-parse.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index a7860ed..02defbb 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -319,12 +319,12 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
 		s = strchr(sb.buf, ' ');
 		if (!s || *sb.buf == ' ') {
 			o->type = OPTION_GROUP;
-			o->help = xstrdup(skipspaces(sb.buf));
+			o->help = leaky(xstrdup(skipspaces(sb.buf)));
 			continue;
 		}
 
 		o->type = OPTION_CALLBACK;
-		o->help = xstrdup(skipspaces(s));
+		o->help = leaky(xstrdup(skipspaces(s)));
 		o->value = &parsed;
 		o->flags = PARSE_OPT_NOARG;
 		o->callback = &parseopt_dump;
@@ -349,10 +349,10 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
 		if (s - sb.buf == 1) /* short option only */
 			o->short_name = *sb.buf;
 		else if (sb.buf[1] != ',') /* long option only */
-			o->long_name = xmemdupz(sb.buf, s - sb.buf);
+			o->long_name = leaky(xmemdupz(sb.buf, s - sb.buf));
 		else {
 			o->short_name = *sb.buf;
-			o->long_name = xmemdupz(sb.buf + 2, s - sb.buf - 2);
+			o->long_name = leaky(xmemdupz(sb.buf + 2, s - sb.buf - 2));
 		}
 	}
 	strbuf_release(&sb);
-- 
1.5.6.120.g3adb8.dirty
Previous: Pierre HabouzitNext: Pierre Habouzit
Message 3 of 9 in “[RFC] leaky()”
  1. Pierre HabouzitJun 24, 2008
  2. 1/2 Introduce leaky().Pierre Habouzit, Jun 24, 2008
  3. 2/2 git-rev-parse: use leaky().Pierre Habouzit, Jun 24, 2008
  4. Pierre HabouzitJun 24, 2008
  5. Jakub NarebskiJun 24, 2008
  6. Pierre HabouzitJun 24, 2008
  7. Junio C HamanoJun 26, 2008
  8. Pierre HabouzitJun 26, 2008
  9. Jan HudecJul 22, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.