[PATCH 2/9] lib: private string map (associative array) API
[notmuch-archives.git] / b1 / 81cfe17e295898085c894fbf06651dac2ec311
1 Return-Path: <too@guru.guru-group.fi>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 051D9431FB6\r
6         for <notmuch@notmuchmail.org>; Fri, 27 Jan 2012 02:59:49 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id 9L9rJBu9UEr2 for <notmuch@notmuchmail.org>;\r
16         Fri, 27 Jan 2012 02:59:48 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66])\r
18         by olra.theworths.org (Postfix) with ESMTP id 58A27431FAE\r
19         for <notmuch@notmuchmail.org>; Fri, 27 Jan 2012 02:59:48 -0800 (PST)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id 3630868056; Fri, 27 Jan 2012 12:59:51 +0200 (EET)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: notmuch@notmuchmail.org\r
24 Subject: [PATCH] moved _notmuch_(get|set)_list () functions earlyer in the\r
25  file\r
26 Date: Fri, 27 Jan 2012 12:59:48 +0200\r
27 Message-Id: <1327661988-18114-1-git-send-email-tomi.ollila@iki.fi>\r
28 X-Mailer: git-send-email 1.7.6.1\r
29 In-Reply-To: <87sjj2ipjh.fsf@nikula.org>\r
30 References: <87sjj2ipjh.fsf@nikula.org>\r
31 Cc: Tomi Ollila <tomi.ollila@iki.fi>\r
32 X-BeenThere: notmuch@notmuchmail.org\r
33 X-Mailman-Version: 2.1.13\r
34 Precedence: list\r
35 List-Id: "Use and development of the notmuch mail system."\r
36         <notmuch.notmuchmail.org>\r
37 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
38         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
39 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
40 List-Post: <mailto:notmuch@notmuchmail.org>\r
41 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
42 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
44 X-List-Received-Date: Fri, 27 Jan 2012 10:59:49 -0000\r
45 \r
46 Moved static functions _notmuch_get_list () and _notmuch_set_list ()\r
47 closer to the beginning of file so that their definition is known\r
48 (without adding forward declarations) in further work.\r
49 \r
50 No functional changes.\r
51 ---\r
52  notmuch-config.c |   84 +++++++++++++++++++++++++++---------------------------\r
53  1 files changed, 42 insertions(+), 42 deletions(-)\r
54 \r
55 diff --git a/notmuch-config.c b/notmuch-config.c\r
56 index 0ded6d7..a124e34 100644\r
57 --- a/notmuch-config.c\r
58 +++ b/notmuch-config.c\r
59 @@ -467,6 +467,48 @@ notmuch_config_save (notmuch_config_t *config)\r
60      return 0;\r
61  }\r
62  \r
63 +static const char **\r
64 +_config_get_list (notmuch_config_t *config,\r
65 +                 const char *section, const char *key,\r
66 +                 const char ***outlist, size_t *list_length, size_t *ret_length)\r
67 +{\r
68 +    assert(outlist);\r
69 +\r
70 +    if (*outlist == NULL) {\r
71 +\r
72 +       char **inlist = g_key_file_get_string_list (config->key_file,\r
73 +                                            section, key, list_length, NULL);\r
74 +       if (inlist) {\r
75 +           unsigned int i;\r
76 +\r
77 +           *outlist = talloc_size (config, sizeof (char *) * (*list_length + 1));\r
78 +\r
79 +           for (i = 0; i < *list_length; i++)\r
80 +               (*outlist)[i] = talloc_strdup (*outlist, inlist[i]);\r
81 +\r
82 +           (*outlist)[i] = NULL;\r
83 +\r
84 +           g_strfreev (inlist);\r
85 +       }\r
86 +    }\r
87 +\r
88 +    if (ret_length)\r
89 +       *ret_length = *list_length;\r
90 +\r
91 +    return *outlist;\r
92 +}\r
93 +\r
94 +static void\r
95 +_config_set_list (notmuch_config_t *config,\r
96 +                 const char *group, const char *name,\r
97 +                 const char *list[],\r
98 +                 size_t length, const char ***config_var )\r
99 +{\r
100 +    g_key_file_set_string_list (config->key_file, group, name, list, length);\r
101 +    talloc_free (*config_var);\r
102 +    *config_var = NULL;\r
103 +}\r
104 +\r
105  const char *\r
106  notmuch_config_get_database_path (notmuch_config_t *config)\r
107  {\r
108 @@ -551,37 +593,6 @@ notmuch_config_set_user_primary_email (notmuch_config_t *config,\r
109      config->user_primary_email = NULL;\r
110  }\r
111  \r
112 -static const char **\r
113 -_config_get_list (notmuch_config_t *config,\r
114 -                 const char *section, const char *key,\r
115 -                 const char ***outlist, size_t *list_length, size_t *ret_length)\r
116 -{\r
117 -    assert(outlist);\r
118 -\r
119 -    if (*outlist == NULL) {\r
120 -\r
121 -       char **inlist = g_key_file_get_string_list (config->key_file,\r
122 -                                            section, key, list_length, NULL);\r
123 -       if (inlist) {\r
124 -           unsigned int i;\r
125 -\r
126 -           *outlist = talloc_size (config, sizeof (char *) * (*list_length + 1));\r
127 -\r
128 -           for (i = 0; i < *list_length; i++)\r
129 -               (*outlist)[i] = talloc_strdup (*outlist, inlist[i]);\r
130 -\r
131 -           (*outlist)[i] = NULL;\r
132 -\r
133 -           g_strfreev (inlist);\r
134 -       }\r
135 -    }\r
136 -\r
137 -    if (ret_length)\r
138 -       *ret_length = *list_length;\r
139 -\r
140 -    return *outlist;\r
141 -}\r
142 -\r
143  const char **\r
144  notmuch_config_get_user_other_email (notmuch_config_t *config,   size_t *length)\r
145  {\r
146 @@ -598,17 +609,6 @@ notmuch_config_get_new_tags (notmuch_config_t *config,   size_t *length)\r
147                              &(config->new_tags_length), length);\r
148  }\r
149  \r
150 -static void\r
151 -_config_set_list (notmuch_config_t *config,\r
152 -                 const char *group, const char *name,\r
153 -                 const char *list[],\r
154 -                 size_t length, const char ***config_var )\r
155 -{\r
156 -    g_key_file_set_string_list (config->key_file, group, name, list, length);\r
157 -    talloc_free (*config_var);\r
158 -    *config_var = NULL;\r
159 -}\r
160 -\r
161  void\r
162  notmuch_config_set_user_other_email (notmuch_config_t *config,\r
163                                      const char *list[],\r
164 -- \r
165 1.7.8.2\r
166 \r