diff options
| author | David Bremner <david@tethera.net> | 2017-02-16 23:07:50 -0400 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2017-02-18 22:18:06 -0400 |
| commit | 0e037c34dd4b7eb9be96e62e0ee18260291de1b2 (patch) | |
| tree | d92b8d55e3e7f2797c8a32628dc02ddb9f5b0a0a /lib/database.cc | |
| parent | e30fa4182fbae7b302d1e90de9f36a8d08a47c1b (diff) | |
lib: Let Xapian manage the memory for FieldProcessors
It turns out this is exactly what release() is for; Xapian will
deallocate the objects when it's done with them.
Diffstat (limited to 'lib/database.cc')
| -rw-r--r-- | lib/database.cc | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/database.cc b/lib/database.cc index b954b34c..8016c4df 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -1030,10 +1030,14 @@ notmuch_database_open_verbose (const char *path, #if HAVE_XAPIAN_FIELD_PROCESSOR /* This currently relies on the query parser to pass anything * with a .. to the range processor */ - notmuch->date_field_processor = new DateFieldProcessor(); - notmuch->query_parser->add_boolean_prefix("date", notmuch->date_field_processor); - notmuch->query_field_processor = new QueryFieldProcessor (*notmuch->query_parser, notmuch); - notmuch->query_parser->add_boolean_prefix("query", notmuch->query_field_processor); + { + Xapian::FieldProcessor * date_fp = new DateFieldProcessor(); + Xapian::FieldProcessor * query_fp = + new QueryFieldProcessor (*notmuch->query_parser, notmuch); + + notmuch->query_parser->add_boolean_prefix("date", date_fp->release ()); + notmuch->query_parser->add_boolean_prefix("query", query_fp->release ()); + } #endif notmuch->last_mod_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_LAST_MOD, "lastmod:"); @@ -1126,13 +1130,6 @@ notmuch_database_close (notmuch_database_t *notmuch) delete notmuch->last_mod_range_processor; notmuch->last_mod_range_processor = NULL; -#if HAVE_XAPIAN_FIELD_PROCESSOR - delete notmuch->date_field_processor; - notmuch->date_field_processor = NULL; - delete notmuch->query_field_processor; - notmuch->query_field_processor = NULL; -#endif - return status; } |
