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

Re: [PATCH] diff-options: add --stat (take 2)

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Apr 13, 2006, 23:09 UTC
Message-ID
<Pine.LNX.4.63.0604140108280.25088@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<Pine.LNX.4.63.0604140012560.10924@wbgn013.biozentrum.uni-wuerzburg.de>
... and a fix for an invalid free():
---
 diff.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
14d8e3c7cda1e2aaff62375fe34db2458d302173
diff --git a/diff.c b/diff.c
index ad8478b..2968153 100644
--- a/diff.c
+++ b/diff.c
@@ -266,7 +266,7 @@ static void show_stats(struct diffstat_t
 			char *qname = xmalloc(len + 1);
 			quote_c_style(name, qname, NULL, 0);
 			free(name);
-			name = qname;
+			data->files[i]->name = name = qname;
 		}
 
 		/*
@@ -297,10 +297,10 @@ static void show_stats(struct diffstat_t
 		if (added < 0) {
 			/* binary file */
 			printf(" %s%-*s |  Bin\n", prefix, len, name);
-			continue;
+			goto free_diffstat_file;
 		} else if (added + deleted == 0) {
 			total_files--;
-			continue;
+			goto free_diffstat_file;
 		}
 
 		add = added;
@@ -314,11 +314,11 @@ static void show_stats(struct diffstat_t
 			add = (add * max + max_change / 2) / max_change;
 			del = total - add;
 		}
-		/* TODO: binary */
 		printf(" %s%-*s |%5d %.*s%.*s\n", prefix,
 				len, name, added + deleted,
 				add, pluses, del, minuses);
-		free(name);
+	free_diffstat_file:
+		free(data->files[i]->name);
 		free(data->files[i]);
 	}
 	free(data->files);
-- 
1.3.0.rc3.g9813
Previous: Johannes SchindelinNext: Junio C Hamano
Message 2 of 3 in “diff-options: add --stat (take 2)”
  1. diff-options: add --stat (take 2)Johannes Schindelin, Apr 13, 2006
  2. Johannes SchindelinApr 13, 2006
  3. diff --stat: no need to ask funcnames nor context.Junio C Hamano, Apr 14, 2006

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.