mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-02-17 23:53:15 +01:00
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.
This commit is contained in:
parent
e30fa4182f
commit
0e037c34dd
2 changed files with 8 additions and 15 deletions
|
@ -211,10 +211,6 @@ struct _notmuch_database {
|
||||||
Xapian::TermGenerator *term_gen;
|
Xapian::TermGenerator *term_gen;
|
||||||
Xapian::ValueRangeProcessor *value_range_processor;
|
Xapian::ValueRangeProcessor *value_range_processor;
|
||||||
Xapian::ValueRangeProcessor *date_range_processor;
|
Xapian::ValueRangeProcessor *date_range_processor;
|
||||||
#if HAVE_XAPIAN_FIELD_PROCESSOR
|
|
||||||
Xapian::FieldProcessor *date_field_processor;
|
|
||||||
Xapian::FieldProcessor *query_field_processor;
|
|
||||||
#endif
|
|
||||||
Xapian::ValueRangeProcessor *last_mod_range_processor;
|
Xapian::ValueRangeProcessor *last_mod_range_processor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1030,10 +1030,14 @@ notmuch_database_open_verbose (const char *path,
|
||||||
#if HAVE_XAPIAN_FIELD_PROCESSOR
|
#if HAVE_XAPIAN_FIELD_PROCESSOR
|
||||||
/* This currently relies on the query parser to pass anything
|
/* This currently relies on the query parser to pass anything
|
||||||
* with a .. to the range processor */
|
* with a .. to the range processor */
|
||||||
notmuch->date_field_processor = new DateFieldProcessor();
|
{
|
||||||
notmuch->query_parser->add_boolean_prefix("date", notmuch->date_field_processor);
|
Xapian::FieldProcessor * date_fp = new DateFieldProcessor();
|
||||||
notmuch->query_field_processor = new QueryFieldProcessor (*notmuch->query_parser, notmuch);
|
Xapian::FieldProcessor * query_fp =
|
||||||
notmuch->query_parser->add_boolean_prefix("query", notmuch->query_field_processor);
|
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
|
#endif
|
||||||
notmuch->last_mod_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_LAST_MOD, "lastmod:");
|
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;
|
delete notmuch->last_mod_range_processor;
|
||||||
notmuch->last_mod_range_processor = NULL;
|
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;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue