- if (max_messages == -1)
- max_messages = notmuch->xapian_db->get_doccount ();
- mset = enquire.get_mset (first, max_messages);
-
- for (i = mset.begin (); i != mset.end (); i++) {
- notmuch_message_t *message;
- notmuch_private_status_t status;
-
- message = _notmuch_message_create (message_list, notmuch,
- *i, &status);
- if (message == NULL)
- {
- if (status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND)
- INTERNAL_ERROR ("A message iterator contains a "
- "non-existent document ID.\n");
- break;
- }
-
- _notmuch_message_list_add_message (message_list, message);
- }
+ mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount ());
+
+ messages->iterator = mset.begin ();
+ messages->iterator_end = mset.end ();