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

[PATCH v3 1/7] strbuf: remove unnecessary NUL assignment in xstrdup_tolower()

From
lars.schneider@autodesk.com <lars.schneider@autodesk.com>
Date
Jan 6, 2018, 00:48 UTC
Message-ID
<20180106004808.77513-2-lars.schneider@autodesk.com>
In-Reply-To
<20180106004808.77513-1-lars.schneider@autodesk.com>
From: Lars Schneider <larsxschneider@gmail.com>

Since 3733e69464 (use xmallocz to avoid size arithmetic, 2016-02-22) we allocate the buffer for the lower case string with xmallocz(). This already ensures a NUL at the end of the allocated buffer.

Remove the unnecessary assignment.
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
---
 strbuf.c | 1 -
 1 file changed, 1 deletion(-)
diff --git a/strbuf.c b/strbuf.c
index 323c49ceb3..b5d03a5029 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -756,7 +756,6 @@ char *xstrdup_tolower(const char *string)
 	result = xmallocz(len);
 	for (i = 0; i < len; i++)
 		result[i] = tolower(string[i]);
-	result[i] = '\0';
 	return result;
 }
 
-- 
2.15.1
Previous: lars.schneider@autodesk.comNext: lars.schneider@autodesk.com
Message 2 of 15 in “convert: add support for different encodings”
  1. 0/7 convert: add support for different encodingslars.schneider@autodesk.com, Jan 6, 2018
  2. 1/7 strbuf: remove unnecessary NUL assignment in xstrdup_tolower()lars.schneider@autodesk.com, Jan 6, 2018
  3. 3/7 utf8: add function to detect prohibited UTF-16/32 BOMlars.schneider@autodesk.com, Jan 6, 2018
  4. 2/7 strbuf: add xstrdup_toupper()lars.schneider@autodesk.com, Jan 6, 2018
  5. 4/7 utf8: add function to detect a missing UTF-16/32 BOMlars.schneider@autodesk.com, Jan 6, 2018
  6. 5/7 convert_to_git(): safe_crlf/checksafe becomes int conv_flagslars.schneider@autodesk.com, Jan 6, 2018
  7. Junio C HamanoJan 8, 2018
  8. Lars SchneiderJan 8, 2018
  9. Junio C HamanoJan 8, 2018
  10. Torsten BögershausenJan 9, 2018
  11. 6/7 convert: add support for 'checkout-encoding' attributelars.schneider@autodesk.com, Jan 6, 2018
  12. 7/7 convert: add tracing for checkout-encodinglars.schneider@autodesk.com, Jan 6, 2018
  13. Torsten BögershausenJan 7, 2018
  14. Lars SchneiderJan 8, 2018
  15. Torsten BögershausenJan 8, 2018

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.