[PATCH 2/3] util: add xtalloc.[ch]
authordavid <david@tethera.net>
Mon, 17 Dec 2012 03:24:06 +0000 (23:24 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:52:28 +0000 (09:52 -0800)
1c/3ac34e70296b71670137720280fa8a48f2d1e7 [new file with mode: 0644]

diff --git a/1c/3ac34e70296b71670137720280fa8a48f2d1e7 b/1c/3ac34e70296b71670137720280fa8a48f2d1e7
new file mode 100644 (file)
index 0000000..e2a1bae
--- /dev/null
@@ -0,0 +1,141 @@
+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 D1F23431FC2\r
+       for <notmuch@notmuchmail.org>; Sun, 16 Dec 2012 19:24:29 -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 NJSJICkb0zdg for <notmuch@notmuchmail.org>;\r
+       Sun, 16 Dec 2012 19:24:28 -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 413FA431E62\r
+       for <notmuch@notmuchmail.org>; Sun, 16 Dec 2012 19:24:26 -0800 (PST)\r
+Received: from fctnnbsc30w-142167090129.dhcp-dynamic.fibreop.nb.bellaliant.net\r
+       ([142.167.90.129] 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 1TkRJZ-0008Jl-AJ; Sun, 16 Dec 2012 23:24:25 -0400\r
+Received: from bremner by zancas.localnet with local (Exim 4.80)\r
+       (envelope-from <bremner@tethera.net>)\r
+       id 1TkRJT-00063P-OV; Sun, 16 Dec 2012 23:24:19 -0400\r
+From: david@tethera.net\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/3] util: add xtalloc.[ch]\r
+Date: Sun, 16 Dec 2012 23:24:06 -0400\r
+Message-Id: <1355714648-23144-3-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1355714648-23144-1-git-send-email-david@tethera.net>\r
+References: <1355714648-23144-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: Mon, 17 Dec 2012 03:24:30 -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/xtalloc.c      |   15 +++++++++++++++\r
+ util/xtalloc.h      |   18 ++++++++++++++++++\r
+ 4 files changed, 35 insertions(+), 2 deletions(-)\r
+ create mode 100644 util/xtalloc.c\r
+ create mode 100644 util/xtalloc.h\r
+\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index d7b352e..60be030 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 "xtalloc.h"\r
\r
+ #define unused(x) x __attribute__ ((unused))\r
\r
+diff --git a/util/Makefile.local b/util/Makefile.local\r
+index a11e35b..8a62c00 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)/xtalloc.c\r
\r
+ libutil_modules := $(libutil_c_srcs:.c=.o)\r
\r
+diff --git a/util/xtalloc.c b/util/xtalloc.c\r
+new file mode 100644\r
+index 0000000..22834bd\r
+--- /dev/null\r
++++ b/util/xtalloc.c\r
+@@ -0,0 +1,15 @@\r
++#include <string.h>\r
++#include "xtalloc.h"\r
++\r
++char *\r
++xtalloc_strndup_named_const (void *ctx, const char *str,\r
++                           size_t len, const char *name)\r
++{\r
++    char *ptr = talloc_named_const (ctx, len + 1, name);\r
++\r
++    if (ptr) {\r
++      memcpy (ptr, str, len);\r
++      *(ptr + len) = '\0';\r
++    }\r
++    return ptr;\r
++}\r
+diff --git a/util/xtalloc.h b/util/xtalloc.h\r
+new file mode 100644\r
+index 0000000..3cc1179\r
+--- /dev/null\r
++++ b/util/xtalloc.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
++xtalloc_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 xtalloc_strndup(ctx, str, len) xtalloc_strndup_named_const (ctx, str, len, __location__)\r
++\r
++#endif\r
+-- \r
+1.7.10.4\r
+\r