-/* We end up having to call the destructors explicitly because we had
- * to use "placement new" in order to initialize C++ objects within a
- * block that we allocated with talloc. So C++ is making talloc
- * slightly less simple to use, (we wouldn't need
- * talloc_set_destructor at all otherwise).
- */
-static int
-_notmuch_terms_destructor (notmuch_terms_t *terms)
-{
- terms->iterator.~TermIterator ();
- terms->iterator_end.~TermIterator ();
-
- return 0;
-}
-
-notmuch_terms_t *
-_notmuch_terms_create (void *ctx,
- Xapian::Document doc,
- const char *prefix_name)
-{
- notmuch_terms_t *terms;
- const char *prefix = _find_prefix (prefix_name);
-
- /* Currently, notmuch_terms_t is written with the assumption that
- * any prefix its derivatives use will be only a single
- * character. */
- assert (strlen (prefix) == 1);
-
- terms = talloc (ctx, notmuch_terms_t);
- if (unlikely (terms == NULL))
- return NULL;
-
- terms->prefix_char = *prefix;
- new (&terms->iterator) Xapian::TermIterator;
- new (&terms->iterator_end) Xapian::TermIterator;
-
- talloc_set_destructor (terms, _notmuch_terms_destructor);
-
- terms->iterator = doc.termlist_begin ();
- terms->iterator.skip_to (prefix);
- terms->iterator_end = doc.termlist_end ();
-
- return terms;
-}
-
-/* The assertion is to ensure that 'type' is a derivative of
- * notmuch_terms_t in that it contains a notmuch_terms_t as its first
- * member. We do this by name of 'terms' as opposed to type, because
- * that's as clever as I've been so far. */
-#define _notmuch_terms_create_type(ctx, doc, prefix_name, type) \
- (COMPILE_TIME_ASSERT(offsetof(type, terms) == 0), \
- (type *) _notmuch_terms_create (ctx, doc, prefix_name))
-