Re: bug#6214: 23.1; json-read-string crashes emacs with long string
[notmuch-archives.git] / 00 / 8993bb6df07b213c6d4f52e0f30e096a09d0c9
1 Return-Path: <meskio@sindominio.net>\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 DE4764196F0\r
6         for <notmuch@notmuchmail.org>; Sat, 20 Mar 2010 03:21:31 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.9\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9] autolearn=ham\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 4EZe0y+-JFrd for <notmuch@notmuchmail.org>;\r
16         Sat, 20 Mar 2010 03:21:31 -0700 (PDT)\r
17 Received: from flatline.sindominio.net (flatline.sindominio.net [82.144.4.26])\r
18         by olra.theworths.org (Postfix) with ESMTP id 8E1A8431FC1\r
19         for <notmuch@notmuchmail.org>; Sat, 20 Mar 2010 03:21:28 -0700 (PDT)\r
20 Received: from localhost (localhost.localdomain [127.0.0.1])\r
21         by flatline.sindominio.net (Postfix) with ESMTP id 3358E262E3D;\r
22         Sat, 20 Mar 2010 11:21:27 +0100 (CET)\r
23 X-Virus-Scanned: Debian amavisd-new at sindominio.net\r
24 Received: from flatline.sindominio.net ([127.0.0.1])\r
25         by localhost (flatline.sindominio.net [127.0.0.1]) (amavisd-new,\r
26         port 10024)\r
27         with ESMTP id xDkq1D1zhmB1; Sat, 20 Mar 2010 11:21:24 +0100 (CET)\r
28 Received: from blackspot (heal.cauterized.net [89.140.131.167])\r
29         by flatline.sindominio.net (Postfix) with ESMTPA id A238A262E3B;\r
30         Sat, 20 Mar 2010 11:21:21 +0100 (CET)\r
31 Received: by blackspot (Postfix, from userid 1000)\r
32         id 1085B8BDF7; Sat, 20 Mar 2010 11:24:34 +0100 (CET)\r
33 From: Ruben Pollan <meskio@sindominio.net>\r
34 To: notmuch@notmuchmail.org\r
35 Date: Sat, 20 Mar 2010 11:23:21 +0100\r
36 Message-Id: <1269080605-5617-2-git-send-email-meskio@sindominio.net>\r
37 X-Mailer: git-send-email 1.7.0\r
38 In-Reply-To: <873a09jt2t.fsf@yoom.home.cworth.org>\r
39 References: <873a09jt2t.fsf@yoom.home.cworth.org>\r
40 Subject: [notmuch] [PATCH 1/5] Convert notmuch_message_list_t in a doubly\r
41         linked\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46         <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Sat, 20 Mar 2010 10:21:32 -0000\r
55 \r
56 The messages list now have pointers to previous nodes, so it is possible\r
57 to iterate backwards.\r
58 ---\r
59  lib/messages.c        |   18 +++++++++++++-----\r
60  lib/notmuch-private.h |    3 ++-\r
61  lib/thread.cc         |    4 ++--\r
62  3 files changed, 17 insertions(+), 8 deletions(-)\r
63 \r
64 diff --git a/lib/messages.c b/lib/messages.c\r
65 index db2b7a1..2a85774 100644\r
66 --- a/lib/messages.c\r
67 +++ b/lib/messages.c\r
68 @@ -37,20 +37,28 @@ _notmuch_message_list_create (const void *ctx)\r
69         return NULL;\r
70  \r
71      list->head = NULL;\r
72 -    list->tail = &list->head;\r
73 +    list->tail = NULL;\r
74  \r
75      return list;\r
76  }\r
77  \r
78 -/* Append 'node' (which can of course point to an arbitrarily long\r
79 - * list of nodes) to the end of 'list'.\r
80 +/* Append 'node' to the end of 'list'.\r
81   */\r
82  void\r
83  _notmuch_message_list_append (notmuch_message_list_t *list,\r
84                               notmuch_message_node_t *node)\r
85  {\r
86 -    *(list->tail) = node;\r
87 -    list->tail = &node->next;\r
88 +    node->prev = list->tail;\r
89 +    if (list->head)\r
90 +    {\r
91 +        list->tail->next = node;\r
92 +    }\r
93 +    else\r
94 +    {\r
95 +        list->head = node;\r
96 +        list->tail = node;\r
97 +    }\r
98 +    list->tail = node;\r
99  }\r
100  \r
101  /* Allocate a new node for 'message' and append it to the end of\r
102 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
103 index d52d84d..3b3f0eb 100644\r
104 --- a/lib/notmuch-private.h\r
105 +++ b/lib/notmuch-private.h\r
106 @@ -349,11 +349,12 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,\r
107  typedef struct _notmuch_message_node {\r
108      notmuch_message_t *message;\r
109      struct _notmuch_message_node *next;\r
110 +    struct _notmuch_message_node *prev;\r
111  } notmuch_message_node_t;\r
112  \r
113  typedef struct _notmuch_message_list {\r
114      notmuch_message_node_t *head;\r
115 -    notmuch_message_node_t **tail;\r
116 +    notmuch_message_node_t *tail;\r
117  } notmuch_message_list_t;\r
118  \r
119  /* There's a rumor that there's an alternate struct _notmuch_messages\r
120 diff --git a/lib/thread.cc b/lib/thread.cc\r
121 index ec80f85..05d2c39 100644\r
122 --- a/lib/thread.cc\r
123 +++ b/lib/thread.cc\r
124 @@ -169,8 +169,8 @@ _resolve_thread_relationships (unused (notmuch_thread_t *thread))\r
125                                           (void **) &parent))\r
126         {\r
127             *prev = node->next;\r
128 -           if (thread->message_list->tail == &node->next)\r
129 -               thread->message_list->tail = prev;\r
130 +           if (thread->message_list->tail == node)\r
131 +               thread->message_list->tail = node->prev;\r
132             node->next = NULL;\r
133             _notmuch_message_add_reply (parent, node);\r
134         } else {\r
135 -- \r
136 1.7.0\r
137 \r