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

[PATCH 2/2] dir: simplify fill_directory()

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
May 11, 2012, 14:59 UTC
Message-ID
<4FAD294D.4010101@lsrfire.ath.cx>
In-Reply-To
<4FAD27D3.7070208@lsrfire.ath.cx>

Now that read_directory_recursive() (reached through read_directory()) respects the string length limit we provide, we don't need to create a NUL-limited copy of the common prefix anymore.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 dir.c |    9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/dir.c b/dir.c
index d5444fb..ed1510f 100644
--- a/dir.c
+++ b/dir.c
@@ -74,7 +74,6 @@ char *common_prefix(const char **pathspec)
 
 int fill_directory(struct dir_struct *dir, const char **pathspec)
 {
-	const char *path;
 	size_t len;
 
 	/*
@@ -82,15 +81,9 @@ int fill_directory(struct dir_struct *dir, const char **pathspec)
 	 * use that to optimize the directory walk
 	 */
 	len = common_prefix_len(pathspec);
-	path = "";
-
-	if (len)
-		path = xmemdupz(*pathspec, len);
 
 	/* Read the directory and prune it */
-	read_directory(dir, path, len, pathspec);
-	if (*path)
-		free((char *)path);
+	read_directory(dir, pathspec ? *pathspec : "", len, pathspec);
 	return len;
 }
 
-- 
1.7.10.1
Previous: René Scharfe
Message 2 of 2 in “dir: respect string length argument of read_directory_recursive()”
  1. 1/2 dir: respect string length argument of read_directory_recursive()René Scharfe, May 11, 2012
  2. 2/2 dir: simplify fill_directory()René Scharfe, May 11, 2012

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.