Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id A3F0D6DE1459 for ; Sat, 9 Jan 2016 18:52:24 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.312 X-Spam-Level: X-Spam-Status: No, score=-0.312 tagged_above=-999 required=5 tests=[AWL=0.239, RP_MATCHES_RCVD=-0.55, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ztSQc4e20zrU for ; Sat, 9 Jan 2016 18:52:23 -0800 (PST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 455036DE02DA for ; Sat, 9 Jan 2016 18:51:59 -0800 (PST) Received: from remotemail by fethera.tethera.net with local (Exim 4.84) (envelope-from ) id 1aI66f-0007E4-8H; Sat, 09 Jan 2016 21:51:49 -0500 Received: (nullmailer pid 29654 invoked by uid 1000); Sun, 10 Jan 2016 02:51:47 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [WIP patch 6/9] lib: add notmuch_metadata_destroy Date: Sat, 9 Jan 2016 22:51:38 -0400 Message-Id: <1452394301-29499-7-git-send-email-david@tethera.net> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1452394301-29499-1-git-send-email-david@tethera.net> References: <1452394301-29499-1-git-send-email-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Jan 2016 02:52:24 -0000 --- 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