[WIP patch 6/9] lib: add notmuch_metadata_destroy

David Bremner david at tethera.net
Sat Jan 9 18:51:38 PST 2016


---
 lib/metadata.cc       |  6 ++++++
 lib/notmuch.h         | 14 +++++++++++++-
 test/T590-metadata.sh |  1 +
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/lib/metadata.cc b/lib/metadata.cc
index a355b75..79a0a9e 100644
--- a/lib/metadata.cc
+++ b/lib/metadata.cc
@@ -245,3 +245,9 @@ notmuch_metadata_move_to_next (notmuch_metadata_t *metadata)
 {
     (*(metadata->iterator))++;
 }
+
+void
+notmuch_metadata_destroy (notmuch_metadata_t *metadata)
+{
+    talloc_free (metadata);
+}
diff --git a/lib/notmuch.h b/lib/notmuch.h
index b00126d..6773253 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -1869,12 +1869,18 @@ notmuch_metadata_valid (notmuch_metadata_t *metadata);
 
 /**
  * return key for current metadata pair
+ *
+ * return value is owned by the iterator, and will be destroyed by the
+ * next call to notmuch_metadata_key or notmuch_metadata_destroy.
  */
 const char *
 notmuch_metadata_key (notmuch_metadata_t *metadata);
 
 /**
- * return value for current metadata pair
+ * return 'value' for current metadata pair
+ *
+ * return value is owned by the iterator, and will be destroyed by the
+ * next call to notmuch_metadata_value
  */
 const char *
 notmuch_metadata_value (notmuch_metadata_t *metadata);
@@ -1885,6 +1891,12 @@ notmuch_metadata_value (notmuch_metadata_t *metadata);
 void
 notmuch_metadata_move_to_next (notmuch_metadata_t *metadata);
 
+/**
+ * free any resources held by 'metadata'
+ */
+void
+notmuch_metadata_destroy (notmuch_metadata_t * metadata);
+
 /* @} */
 
 NOTMUCH_END_DECLS
diff --git a/test/T590-metadata.sh b/test/T590-metadata.sh
index 4f37c09..4d55298 100755
--- a/test/T590-metadata.sh
+++ b/test/T590-metadata.sh
@@ -64,6 +64,7 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
       printf("key = %s\n", notmuch_metadata_key (meta));
       printf("val = %s\n", notmuch_metadata_value (meta));
    }
+   notmuch_metadata_destroy (meta);
 }
 EOF
 cat <<'EOF' >EXPECTED
-- 
2.6.4



More information about the notmuch mailing list