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

[PATCH 2/2] Use ALLOC_GROW in builtin/push.c

From
Jared Hance <jaredhance@gmail.com>
Date
Jul 31, 2010, 12:57 UTC
Message-ID
<fbf6f49fa7c1d6b265d6cf6cfa772ec133550389.1280580026.git.jaredhance@gmail.com>
In-Reply-To
<cover.1280580026.git.jaredhance@gmail.com>

The current implementation of add_refspec(const char *ref) duplicates functionality found in the xalloc api. Use ALLOC_GROW instead to prevent code duplication.

Signed-off-by: Jared Hance <jaredhance@gmail.com>
---
 builtin/push.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin/push.c b/builtin/push.c
index 79d8192..0da0ec8 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -22,11 +22,12 @@ static int progress;
 
 static const char **refspec;
 static int refspec_nr;
+static size_t refspec_alloc;
 
 static void add_refspec(const char *ref)
 {
 	refspec_nr++;
-	refspec = xrealloc(refspec, refspec_nr * sizeof(char *));
+	ALLOC_GROW(refspec, refspec_nr, refspec_alloc);
 	refspec[refspec_nr-1] = ref;
 }
 
-- 
1.7.2
Previous: Junio C Hamano
Message 6 of 6 in “Remove useless temporary integer in builtin/push.c”
  1. Remove useless temporary integer in builtin/push.cJared Hance, Jul 29, 2010
  2. Thomas RastJul 29, 2010
  3. 0/2 Clean up add_refspec in builtin/push.cJared Hance, Jul 31, 2010
  4. 1/2 Remove useless temporary integer in builtin/push.cJared Hance, Jul 31, 2010
  5. Junio C HamanoAug 2, 2010
  6. 2/2 Use ALLOC_GROW in builtin/push.cJared Hance, Jul 31, 2010

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.