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

[PATCH 2/4] builtin-clone: use strbuf in guess_dir_name()

From
Miklos Vajna <vmiklos@frugalware.org>
Date
Nov 21, 2008, 00:44 UTC
Message-ID
<33c4500c44cb27b1bfb3ec5584c0665b0dbd7c73.1227227976.git.vmiklos@frugalware.org>
In-Reply-To
<6bd31bceb3840f14d747972b4858e1c5b215744d.1227227976.git.vmiklos@frugalware.org>
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
 builtin-clone.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin-clone.c b/builtin-clone.c
index da21cab..52b1242 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -134,9 +134,9 @@ static char *guess_dir_name(const char *repo, int is_bundle, int is_bare)
 	}
 
 	if (is_bare) {
-		char *result = xmalloc(end - start + 5);
-		sprintf(result, "%.*s.git", (int)(end - start), start);
-		return result;
+		struct strbuf result = STRBUF_INIT;
+		strbuf_addf(&result, "%.*s.git", (int)(end - start), start);
+		return strbuf_detach(&result, 0);
 	}
 
 	return xstrndup(start, end - start);
-- 
1.6.0.4
Previous: Miklos VajnaNext: Miklos Vajna
Message 3 of 7 in “builtin-clone: use strbuf”
  1. 0/4 builtin-clone: use strbufMiklos Vajna, Nov 21, 2008
  2. 1/4 builtin-clone: fix a memory leak in cmd_clone()Miklos Vajna, Nov 21, 2008
  3. 2/4 builtin-clone: use strbuf in guess_dir_name()Miklos Vajna, Nov 21, 2008
  4. 3/4 builtin-clone: use strbuf in clone_local() and copy_or_link_directory()Miklos Vajna, Nov 21, 2008
  5. 4/4 builtin_clone: use strbuf in cmd_clone()Miklos Vajna, Nov 21, 2008
  6. Junio C HamanoNov 24, 2008
  7. Miklos VajnaNov 25, 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.