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

[PATCH v3 6/6] api-string-list.txt: initialize the string_list the easy way

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Sep 12, 2012, 14:04 UTC
Message-ID
<1347458687-31092-7-git-send-email-mhagger@alum.mit.edu>
In-Reply-To
<1347458687-31092-1-git-send-email-mhagger@alum.mit.edu>

In the demo code blurb, show how to initialize the string_list using STRING_LIST_INIT_NODUP rather than memset().

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 Documentation/technical/api-string-list.txt | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Documentation/technical/api-string-list.txt b/Documentation/technical/api-string-list.txt
index 32b35d9..155ac8c 100644
--- a/Documentation/technical/api-string-list.txt
+++ b/Documentation/technical/api-string-list.txt
@@ -44,10 +44,9 @@ member (you need this if you add things later) and you should set the
 Example:
 
 ----
-struct string_list list;
+struct string_list list = STRING_LIST_INIT_NODUP;
 int i;
 
-memset(&list, 0, sizeof(struct string_list));
 string_list_append(&list, "foo");
 string_list_append(&list, "bar");
 for (i = 0; i < list.nr; i++)
-- 
1.7.11.3
Previous: Michael Haggerty
Message 7 of 7 in “Add some string_list-related functions”
  1. 0/6 Add some string_list-related functionsMichael Haggerty, Sep 12, 2012
  2. 1/6 string_list: add function string_list_append_nodup()Michael Haggerty, Sep 12, 2012
  3. 2/6 string_list: add two new functions for splitting stringsMichael Haggerty, Sep 12, 2012
  4. 3/6 string_list: add a new function, filter_string_list()Michael Haggerty, Sep 12, 2012
  5. 4/6 string_list: add a new function, string_list_remove_duplicates()Michael Haggerty, Sep 12, 2012
  6. 5/6 string_list: add a function string_list_longest_prefix()Michael Haggerty, Sep 12, 2012
  7. 6/6 api-string-list.txt: initialize the string_list the easy wayMichael Haggerty, Sep 12, 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.