[Patch v2 2/4] util: add talloc-extra.[ch]
authordavid <david@tethera.net>
Wed, 26 Dec 2012 21:58:29 +0000 (17:58 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:52:50 +0000 (09:52 -0800)
13/4d218f06323c972e0645acd414e6eb551fbd14 [new file with mode: 0644]

diff --git a/13/4d218f06323c972e0645acd414e6eb551fbd14 b/13/4d218f06323c972e0645acd414e6eb551fbd14
new file mode 100644 (file)
index 0000000..fff7c23
--- /dev/null
@@ -0,0 +1,140 @@
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 678A9431FC2\r
+       for <notmuch@notmuchmail.org>; Wed, 26 Dec 2012 13:58:53 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id S10qE8Uf5qIN for <notmuch@notmuchmail.org>;\r
+       Wed, 26 Dec 2012 13:58:52 -0800 (PST)\r
+Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])\r
+       (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id CD112431FB6\r
+       for <notmuch@notmuchmail.org>; Wed, 26 Dec 2012 13:58:48 -0800 (PST)\r
+Received: from fctnnbsc30w-156034082078.dhcp-dynamic.fibreop.nb.bellaliant.net\r
+       ([156.34.82.78] helo=zancas.localnet)\r
+       by tesseract.cs.unb.ca with esmtpsa\r
+       (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72)\r
+       (envelope-from <bremner@tethera.net>)\r
+       id 1Tnyzw-0002wh-1W; Wed, 26 Dec 2012 17:58:48 -0400\r
+Received: from bremner by zancas.localnet with local (Exim 4.80)\r
+       (envelope-from <bremner@tethera.net>)\r
+       id 1Tnyzq-0002Xt-G5; Wed, 26 Dec 2012 17:58:42 -0400\r
+From: david@tethera.net\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v2 2/4] util: add talloc-extra.[ch]\r
+Date: Wed, 26 Dec 2012 17:58:29 -0400\r
+Message-Id: <1356559111-9447-3-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1356559111-9447-1-git-send-email-david@tethera.net>\r
+References: <1356559111-9447-1-git-send-email-david@tethera.net>\r
+X-Spam_bar: -\r
+Cc: David Bremner <bremner@debian.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 26 Dec 2012 21:58:53 -0000\r
+\r
+From: David Bremner <bremner@debian.org>\r
+\r
+These are intended to be simple wrappers to provide slightly better\r
+debugging information than what talloc currently provides natively.\r
+---\r
+ notmuch-client.h    |    2 +-\r
+ util/Makefile.local |    2 +-\r
+ util/talloc-extra.c |   14 ++++++++++++++\r
+ util/talloc-extra.h |   18 ++++++++++++++++++\r
+ 4 files changed, 34 insertions(+), 2 deletions(-)\r
+ create mode 100644 util/talloc-extra.c\r
+ create mode 100644 util/talloc-extra.h\r
+\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index d7b352e..5f28836 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -58,7 +58,7 @@ typedef GMimeCipherContext notmuch_crypto_context_t;\r
+ #include <errno.h>\r
+ #include <signal.h>\r
\r
+-#include <talloc.h>\r
++#include "talloc-extra.h"\r
\r
+ #define unused(x) x __attribute__ ((unused))\r
\r
+diff --git a/util/Makefile.local b/util/Makefile.local\r
+index a11e35b..29c0ce6 100644\r
+--- a/util/Makefile.local\r
++++ b/util/Makefile.local\r
+@@ -4,7 +4,7 @@ dir := util\r
+ extra_cflags += -I$(srcdir)/$(dir)\r
\r
+ libutil_c_srcs := $(dir)/xutil.c $(dir)/error_util.c $(dir)/hex-escape.c \\r
+-                $(dir)/string-util.c\r
++                $(dir)/string-util.c $(dir)/talloc-extra.c\r
\r
+ libutil_modules := $(libutil_c_srcs:.c=.o)\r
\r
+diff --git a/util/talloc-extra.c b/util/talloc-extra.c\r
+new file mode 100644\r
+index 0000000..4a5f9c0\r
+--- /dev/null\r
++++ b/util/talloc-extra.c\r
+@@ -0,0 +1,14 @@\r
++#include <string.h>\r
++#include "talloc-extra.h"\r
++\r
++char *\r
++talloc_strndup_named_const (void *ctx, const char *str,\r
++                           size_t len, const char *name)\r
++{\r
++    char *ptr = talloc_strndup (ctx, str, len);\r
++\r
++    if (ptr)\r
++      talloc_set_name_const(ptr, name);\r
++\r
++    return ptr;\r
++}\r
+diff --git a/util/talloc-extra.h b/util/talloc-extra.h\r
+new file mode 100644\r
+index 0000000..5b8ca28\r
+--- /dev/null\r
++++ b/util/talloc-extra.h\r
+@@ -0,0 +1,18 @@\r
++#ifndef _XTALLOC_H\r
++#define _XTALLOC_H\r
++\r
++#include <talloc.h>\r
++\r
++/* Like talloc_strndup, but take an extra parameter for the internal talloc\r
++ * name (for debugging) */\r
++\r
++char *\r
++talloc_strndup_named_const (void *ctx, const char *str,\r
++                          size_t len, const char *name);\r
++\r
++/* use the __location__ macro from talloc.h to name a string according to its\r
++ * source location */\r
++\r
++#define talloc_strndup_debug(ctx, str, len) talloc_strndup_named_const (ctx, str, len, __location__)\r
++\r
++#endif\r
+-- \r
+1.7.10.4\r
+\r