aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/directory.cc
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2010-01-06 14:35:11 -0800
committerGravatar Carl Worth <cworth@cworth.org>2010-01-06 14:35:11 -0800
commit957ae198e708dc901e3a8c89b7364c2bc75ce371 (patch)
tree089c3c29ac7e6d96a34bb33fe79acae237ddcf8f /lib/directory.cc
parent7d8271dd9db5affa9fce589424d6f3b4d8b66cd7 (diff)
lib: Treat NULL as a valid (and empty) notmuch_filenames_t iterator.
This will be convenient to avoid some special-casing in higher-level code.
Diffstat (limited to 'lib/directory.cc')
-rw-r--r--lib/directory.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/directory.cc b/lib/directory.cc
index 196f7805..d5015e0a 100644
--- a/lib/directory.cc
+++ b/lib/directory.cc
@@ -81,12 +81,18 @@ _notmuch_filenames_create (void *ctx,
notmuch_bool_t
notmuch_filenames_has_more (notmuch_filenames_t *filenames)
{
+ if (filenames == NULL)
+ return NULL;
+
return (filenames->iterator != filenames->end);
}
const char *
notmuch_filenames_get (notmuch_filenames_t *filenames)
{
+ if (filenames == NULL || filenames->iterator == filenames->end)
+ return NULL;
+
if (filenames->filename == NULL) {
std::string term = *filenames->iterator;
@@ -101,6 +107,9 @@ notmuch_filenames_get (notmuch_filenames_t *filenames)
void
notmuch_filenames_advance (notmuch_filenames_t *filenames)
{
+ if (filenames == NULL)
+ return;
+
if (filenames->filename) {
talloc_free (filenames->filename);
filenames->filename = NULL;
@@ -113,6 +122,9 @@ notmuch_filenames_advance (notmuch_filenames_t *filenames)
void
notmuch_filenames_destroy (notmuch_filenames_t *filenames)
{
+ if (filenames == NULL)
+ return;
+
talloc_free (filenames);
}