X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fquery.cc;h=7916421e4a0068847a0fc13b71514c1258893a42;hp=7e1b6b52984330d82f6c82462f64d02c2450f0f4;hb=d064bd696ccc443a7ece9cfc8816999c69943223;hpb=aadb15a002dc01903d60ca40048d6d4ef3990863 diff --git a/lib/query.cc b/lib/query.cc index 7e1b6b52..7916421e 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -23,8 +23,6 @@ #include /* GHashTable, GPtrArray */ -#include - struct _notmuch_query { notmuch_database_t *notmuch; const char *query_string; @@ -70,12 +68,24 @@ notmuch_query_create (notmuch_database_t *notmuch, return query; } +const char * +notmuch_query_get_query_string (notmuch_query_t *query) +{ + return query->query_string; +} + void notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort) { query->sort = sort; } +notmuch_sort_t +notmuch_query_get_sort (notmuch_query_t *query) +{ + return query->sort; +} + /* 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 @@ -163,14 +173,16 @@ notmuch_query_search_messages (notmuch_query_t *query) messages->iterator = mset.begin (); messages->iterator_end = mset.end (); + return &messages->base; + } catch (const Xapian::Error &error) { fprintf (stderr, "A Xapian exception occurred performing query: %s\n", error.get_msg().c_str()); fprintf (stderr, "Query string was: %s\n", query->query_string); notmuch->exception_reported = TRUE; + talloc_free (messages); + return NULL; } - - return &messages->base; } notmuch_bool_t @@ -247,6 +259,10 @@ notmuch_query_search_threads (notmuch_query_t *query) free, NULL); threads->messages = notmuch_query_search_messages (query); + if (threads->messages == NULL) { + talloc_free (threads); + return NULL; + } threads->thread_id = NULL;