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

[PATCH] parse-options-cb.c: use string_list_append_nodup in OPT_STRING_LIST()

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jun 10, 2016, 11:57 UTC
Message-ID
<20160610115726.4805-1-pclouds@gmail.com>

If the given string list has strdup_strings set (*), the string will be duplicated again. Pointless and leak memory. Ignore that flag.

(*) only interpret-trailers.c does it at the moment
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 parse-options-cb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/parse-options-cb.c b/parse-options-cb.c
index 239898d..8a1b6e6 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -144,7 +144,7 @@ int parse_opt_string_list(const struct option *opt, const char *arg, int unset)
 	if (!arg)
 		return -1;
 
-	string_list_append(v, xstrdup(arg));
+	string_list_append_nodup(v, xstrdup(arg));
 	return 0;
 }
 
-- 
2.8.2.524.g6ff3d78
Next: Jeff King
Message 1 of 15 in “parse-options-cb.c: use string_list_append_nodup in OPT_STRING_LIST()”
  1. parse-options-cb.c: use string_list_append_nodup in OPT_STRING_LIST()Nguyễn Thái Ngọc Duy, Jun 10, 2016
  2. Jeff KingJun 12, 2016
  3. Duy NguyenJun 13, 2016
  4. 0/3 fix parse-opt string_list leaksJeff King, Jun 13, 2016
  5. 1/3 parse_opt_string_list: stop allocating new stringsJeff King, Jun 13, 2016
  6. 2/3 interpret-trailers: don't duplicate option stringsJeff King, Jun 13, 2016
  7. 3/3 blame,shortlog: don't make local option variables staticJeff King, Jun 13, 2016
  8. Eric SunshineJun 14, 2016
  9. Jeff KingJun 14, 2016
  10. blame: drop strdup of string literalJeff King, Aug 2, 2016
  11. Eric SunshineAug 3, 2016
  12. Duy NguyenJun 13, 2016
  13. 4/3 use string_list initializer consistentlyJeff King, Jun 13, 2016
  14. Duy NguyenJun 13, 2016
  15. Jeff KingJun 13, 2016

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.