Re: [PATCH 1/2] Add Google Inc. to AUTHORS as a contributor.
[notmuch-archives.git] / 4b / bf3b7bab2f5d577550104683de01b785a4a0e6
1 Return-Path: <too@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 1D654431FAF\r
6         for <notmuch@notmuchmail.org>; Fri, 21 Dec 2012 09:52:11 -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 CYVTCXvAN+QL for <notmuch@notmuchmail.org>;\r
16         Fri, 21 Dec 2012 09:52:10 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id F4130431FAE\r
19         for <notmuch@notmuchmail.org>; Fri, 21 Dec 2012 09:52:09 -0800 (PST)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id 11DA01001F5; Fri, 21 Dec 2012 19:52:03 +0200 (EET)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: notmuch@notmuchmail.org\r
24 Subject: [PATCH 1/1] lib/message-file.c: use g_malloc () & g_free () in hash\r
25         table values\r
26 Date: Fri, 21 Dec 2012 19:52:01 +0200\r
27 Message-Id: <1356112321-6332-1-git-send-email-tomi.ollila@iki.fi>\r
28 X-Mailer: git-send-email 1.8.0\r
29 Cc: tomi.ollila@iki.fi\r
30 X-BeenThere: notmuch@notmuchmail.org\r
31 X-Mailman-Version: 2.1.13\r
32 Precedence: list\r
33 List-Id: "Use and development of the notmuch mail system."\r
34         <notmuch.notmuchmail.org>\r
35 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
36         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
37 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
38 List-Post: <mailto:notmuch@notmuchmail.org>\r
39 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
40 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
41         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
42 X-List-Received-Date: Fri, 21 Dec 2012 17:52:11 -0000\r
43 \r
44 The message->headers hash table values get data returned by\r
45 g_mime_utils_header_decode_text ().\r
46 \r
47 The pointer returned by g_mime_utils_header_decode_text is from the\r
48 following line in rfc2047_decode_tokens\r
49 \r
50         return g_string_free (decoded, FALSE);\r
51 \r
52 The docs for g_string_free say\r
53 \r
54  Frees the memory allocated for the GString. If free_segment is TRUE\r
55  it also frees the character data. If it's FALSE, the caller gains\r
56  ownership of the buffer and must free it after use with g_free().\r
57 \r
58 The remaining frees and allocations referencing to message->headers hash\r
59 values have been changed to use g_free and g_malloc functions.\r
60 \r
61 This combines and completes the changes started by David Bremner.\r
62 ---\r
63 \r
64 This was meant to be in reply to id:87mwxkptqn.fsf@zancas.localnet\r
65 but I fumbled it. ;)\r
66 \r
67  lib/message-file.c | 8 ++++----\r
68  1 file changed, 4 insertions(+), 4 deletions(-)\r
69 \r
70 diff --git a/lib/message-file.c b/lib/message-file.c\r
71 index 915aba8..4d9af89 100644\r
72 --- a/lib/message-file.c\r
73 +++ b/lib/message-file.c\r
74 @@ -111,7 +111,7 @@ _notmuch_message_file_open_ctx (void *ctx, const char *filename)\r
75      message->headers = g_hash_table_new_full (strcase_hash,\r
76                                               strcase_equal,\r
77                                               free,\r
78 -                                             free);\r
79 +                                             g_free);\r
80  \r
81      message->parsing_started = 0;\r
82      message->parsing_finished = 0;\r
83 @@ -337,11 +337,11 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,\r
84                 /* we need to add the header to those we already collected */\r
85                 newhdr = strlen(decoded_value);\r
86                 hdrsofar = strlen(header_sofar);\r
87 -               combined_header = xmalloc(hdrsofar + newhdr + 2);\r
88 +               combined_header = g_malloc(hdrsofar + newhdr + 2);\r
89                 strncpy(combined_header,header_sofar,hdrsofar);\r
90                 *(combined_header+hdrsofar) = ' ';\r
91                 strncpy(combined_header+hdrsofar+1,decoded_value,newhdr+1);\r
92 -               free (decoded_value);\r
93 +               g_free (decoded_value);\r
94                 g_hash_table_insert (message->headers, header, combined_header);\r
95             }\r
96         } else {\r
97 @@ -350,7 +350,7 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,\r
98                 g_hash_table_insert (message->headers, header, decoded_value);\r
99             } else {\r
100                 free (header);\r
101 -               free (decoded_value);\r
102 +               g_free (decoded_value);\r
103                 decoded_value = header_sofar;\r
104             }\r
105         }\r
106 -- \r
107 1.8.0\r
108 \r