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

[PATCH] strbuf.c: remove unnecessary strbuf_grow() from strbuf_getwholeline()

From
Brandon Casey <drafnel@gmail.com>
Date
Oct 6, 2011, 04:21 UTC
Message-ID
<1317874893-4167-1-git-send-email-drafnel@gmail.com>

This use of strbuf_grow() is a historical artifact that was once used to ensure that strbuf.buf was allocated and properly nul-terminated. This was added before the introduction of the slopbuf in b315c5c0, which guarantees that strbuf.buf always points to a usable nul-terminated string. So let's remove it.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
---
 strbuf.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/strbuf.c b/strbuf.c
index 9ff1b59..3ad2cc0 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -357,7 +357,6 @@ int strbuf_getwholeline(struct strbuf *sb, FILE *fp, int term)
 {
 	int ch;
 
-	strbuf_grow(sb, 0);
 	if (feof(fp))
 		return EOF;
 
-- 
1.7.7.1.ge3b6f
Message 1 of 1 in “strbuf.c: remove unnecessary strbuf_grow() from strbuf_getwholeline()”
  1. strbuf.c: remove unnecessary strbuf_grow() from strbuf_getwholeline()Brandon Casey, Oct 6, 2011

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.