Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 84 / 7f2904528dc119b4bb4a3a54917abbe398f284
1 Return-Path: <teythoon@jade-hamburg.de>\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 299F2431FAF\r
6         for <notmuch@notmuchmail.org>; Wed, 25 Apr 2012 06:20:39 -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: 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 Cq0k9uzcqU6v for <notmuch@notmuchmail.org>;\r
16         Wed, 25 Apr 2012 06:20:38 -0700 (PDT)\r
17 Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68])\r
18         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 0AF1B431FAE\r
21         for <notmuch@notmuchmail.org>; Wed, 25 Apr 2012 06:20:38 -0700 (PDT)\r
22 Received: from mail.jade-hamburg.de (mail.jade-hamburg.de [85.183.11.228])\r
23         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
24         (No client certificate requested)\r
25         by mail.cryptobitch.de (Postfix) with ESMTPSA id 1007358522A\r
26         for <notmuch@notmuchmail.org>; Wed, 25 Apr 2012 15:20:36 +0200 (CEST)\r
27 Received: by mail.jade-hamburg.de (Postfix, from userid 401)\r
28         id 85FA7DF2A3; Wed, 25 Apr 2012 15:20:35 +0200 (CEST)\r
29 Received: from thinkbox.jade-hamburg.de (mail.jade-hamburg.de [85.183.11.228])\r
30         (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
31         (No client certificate requested) (Authenticated sender: teythoon)\r
32         by mail.jade-hamburg.de (Postfix) with ESMTPSA id E22D9DF2A1;\r
33         Wed, 25 Apr 2012 15:20:31 +0200 (CEST)\r
34 Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.77)\r
35         (envelope-from <teythoon@thinkbox.jade-hamburg.de>)\r
36         id 1SN28u-0005Hq-BJ; Wed, 25 Apr 2012 15:20:24 +0200\r
37 From: Justus Winter <4winter@informatik.uni-hamburg.de>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH 1/7] Split notmuch_database_close into two functions\r
40 Date: Wed, 25 Apr 2012 15:20:16 +0200\r
41 Message-Id:\r
42  <1335360016-20289-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
43 X-Mailer: git-send-email 1.7.10\r
44 In-Reply-To: <20120422180159.GG17810@mit.edu>\r
45 References: <20120422180159.GG17810@mit.edu>\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\r
49 List-Id: "Use and development of the notmuch mail system."\r
50         <notmuch.notmuchmail.org>\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
54 List-Post: <mailto:notmuch@notmuchmail.org>\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
58 X-List-Received-Date: Wed, 25 Apr 2012 13:20:39 -0000\r
59 \r
60 Formerly notmuch_database_close closed the xapian database and\r
61 destroyed the talloc structure associated with the notmuch database\r
62 object. Split notmuch_database_close into notmuch_database_close and\r
63 notmuch_database_destroy.\r
64 \r
65 This makes it possible for long running programs to close the xapian\r
66 database and thus release the lock associated with it without\r
67 destroying the data structures obtained from it.\r
68 \r
69 This also makes the api more consistent since every other data\r
70 structure has a destructor function.\r
71 \r
72 The comments in notmuch.h are a courtesy of Austin Clements.\r
73 \r
74 Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>\r
75 ---\r
76  lib/database.cc |   14 ++++++++++++--\r
77  lib/notmuch.h   |   22 ++++++++++++++++++----\r
78  2 files changed, 30 insertions(+), 6 deletions(-)\r
79 \r
80 diff --git a/lib/database.cc b/lib/database.cc\r
81 index 16c4354..2fefcad 100644\r
82 --- a/lib/database.cc\r
83 +++ b/lib/database.cc\r
84 @@ -642,7 +642,7 @@ notmuch_database_open (const char *path,\r
85                          "       read-write mode.\n",\r
86                          notmuch_path, version, NOTMUCH_DATABASE_VERSION);\r
87                 notmuch->mode = NOTMUCH_DATABASE_MODE_READ_ONLY;\r
88 -               notmuch_database_close (notmuch);\r
89 +               notmuch_database_destroy (notmuch);\r
90                 notmuch = NULL;\r
91                 goto DONE;\r
92             }\r
93 @@ -702,7 +702,7 @@ notmuch_database_open (const char *path,\r
94      } catch (const Xapian::Error &error) {\r
95         fprintf (stderr, "A Xapian exception occurred opening database: %s\n",\r
96                  error.get_msg().c_str());\r
97 -       notmuch_database_close (notmuch);\r
98 +       notmuch_database_destroy (notmuch);\r
99         notmuch = NULL;\r
100      }\r
101  \r
102 @@ -738,9 +738,19 @@ notmuch_database_close (notmuch_database_t *notmuch)\r
103      }\r
104  \r
105      delete notmuch->term_gen;\r
106 +    notmuch->term_gen = NULL;\r
107      delete notmuch->query_parser;\r
108 +    notmuch->query_parser = NULL;\r
109      delete notmuch->xapian_db;\r
110 +    notmuch->xapian_db = NULL;\r
111      delete notmuch->value_range_processor;\r
112 +    notmuch->value_range_processor = NULL;\r
113 +}\r
114 +\r
115 +void\r
116 +notmuch_database_destroy (notmuch_database_t *notmuch)\r
117 +{\r
118 +    notmuch_database_close (notmuch);\r
119      talloc_free (notmuch);\r
120  }\r
121  \r
122 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
123 index 673c423..7d9e092 100644\r
124 --- a/lib/notmuch.h\r
125 +++ b/lib/notmuch.h\r
126 @@ -133,7 +133,7 @@ typedef struct _notmuch_filenames notmuch_filenames_t;\r
127   *\r
128   * After a successful call to notmuch_database_create, the returned\r
129   * database will be open so the caller should call\r
130 - * notmuch_database_close when finished with it.\r
131 + * notmuch_database_destroy when finished with it.\r
132   *\r
133   * The database will not yet have any data in it\r
134   * (notmuch_database_create itself is a very cheap function). Messages\r
135 @@ -165,7 +165,7 @@ typedef enum {\r
136   * An existing notmuch database can be identified by the presence of a\r
137   * directory named ".notmuch" below 'path'.\r
138   *\r
139 - * The caller should call notmuch_database_close when finished with\r
140 + * The caller should call notmuch_database_destroy when finished with\r
141   * this database.\r
142   *\r
143   * In case of any failure, this function returns NULL, (after printing\r
144 @@ -175,11 +175,25 @@ notmuch_database_t *\r
145  notmuch_database_open (const char *path,\r
146                        notmuch_database_mode_t mode);\r
147  \r
148 -/* Close the given notmuch database, freeing all associated\r
149 - * resources. See notmuch_database_open. */\r
150 +/* Close the given notmuch database.\r
151 + *\r
152 + * After notmuch_database_close has been called, calls to other\r
153 + * functions on objects derived from this database may either behave\r
154 + * as if the database had not been closed (e.g., if the required data\r
155 + * has been cached) or may fail with a\r
156 + * NOTMUCH_STATUS_XAPIAN_EXCEPTION.\r
157 + *\r
158 + * notmuch_database_close can be called multiple times.  Later calls\r
159 + * have no effect.\r
160 + */\r
161  void\r
162  notmuch_database_close (notmuch_database_t *database);\r
163  \r
164 +/* Destroy the notmuch database, closing it if necessary and freeing\r
165 +* all associated resources. */\r
166 +void\r
167 +notmuch_database_destroy (notmuch_database_t *database);\r
168 +\r
169  /* Return the database path of the given database.\r
170   *\r
171   * The return value is a string owned by notmuch so should not be\r
172 -- \r
173 1.7.10\r
174 \r