--- /dev/null
+Return-Path: <amdragon@mit.edu>\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 76588431FAF\r
+ for <notmuch@notmuchmail.org>; Thu, 20 Dec 2012 18:04:03 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 pBTTMiRn5gUr for <notmuch@notmuchmail.org>;\r
+ Thu, 20 Dec 2012 18:04:03 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
+ [18.9.25.15])\r
+ by olra.theworths.org (Postfix) with ESMTP id CFB6E431FAE\r
+ for <notmuch@notmuchmail.org>; Thu, 20 Dec 2012 18:04:02 -0800 (PST)\r
+X-AuditID: 1209190f-b7f016d000000e07-6d-50d3c39134a2\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id FA.64.03591.193C3D05; Thu, 20 Dec 2012 21:04:01 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id qBL240r2027304; \r
+ Thu, 20 Dec 2012 21:04:00 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qBL23w0s003488\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Thu, 20 Dec 2012 21:03:59 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1Tlrxu-0007Ku-IZ; Thu, 20 Dec 2012 21:03:58 -0500\r
+Date: Thu, 20 Dec 2012 21:03:58 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: david@tethera.net\r
+Subject: Re: [PATCH 2/3] util: add xtalloc.[ch]\r
+Message-ID: <20121221020358.GR6187@mit.edu>\r
+References: <1355714648-23144-1-git-send-email-david@tethera.net>\r
+ <1355714648-23144-3-git-send-email-david@tethera.net>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <1355714648-23144-3-git-send-email-david@tethera.net>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFupmleLIzCtJLcpLzFFi42IRYrdT1514+HKAQcMGFYuNy34yW9xo7Wa0\r
+ uH5zJrMDs8evtrnMHs9W3WL22HLoPXMAcxSXTUpqTmZZapG+XQJXxoStW9kLFolXLLz3ha2B\r
+ cY1QFyMnh4SAicSGpReZIWwxiQv31rOB2EIC+xglFr5k6mLkArI3MEpMujCTHcK5yCTRfe0M\r
+ C4SzhFGi/UcDWDuLgKrEkb/HwdrZBDQktu1fzghiiwiISpzeNIkVxGYWsJdYNHsS0CQODmEB\r
+ fYnPH+1ATF4BbYmFv7UgFldK7Pu/gR3E5hUQlDg58wkLRKeWxI1/IAdxANnSEsv/cYCEOQWc\r
+ JKb/2gg2XFRARWLKyW1sExiFZiHpnoWkexZC9wJG5lWMsim5Vbq5iZk5xanJusXJiXl5qUW6\r
+ Jnq5mSV6qSmlmxhBYc4pyb+D8dtBpUOMAhyMSjy8ERaXA4RYE8uKK3MPMUpyMCmJ8urtBwrx\r
+ JeWnVGYkFmfEF5XmpBYfYpTgYFYS4X2+BCjHm5JYWZValA+TkuZgURLnvZpy019IID2xJDU7\r
+ NbUgtQgmK8PBoSTBO+8QUKNgUWp6akVaZk4JQpqJgxNkOA/Q8OkgNbzFBYm5xZnpEPlTjIpS\r
+ 4rztIAkBkERGaR5cLywNvWIUB3pFmFcdpIoHmMLgul8BDWYCGhykdwFkcEkiQkqqgTGYb73y\r
+ oilLp00+tTHRKvuUcu6eRxrdjI+VP8+/URkTs+tGxK63XGlRR23Y5Np58rYWb+BOmyW6/CXL\r
+ sWP+NocCDBd4ycyL5P94I+lAxilzAXHW7bM/TRdp+KBuVHgxMfJzRoP/8yXF+3v1khqunju3\r
+ f3a1pu2yNZ/b6l5bxqdYtD1dtkjH67USS3FGoqEWc1FxIgDsMh1wHgMAAA==\r
+Cc: notmuch@notmuchmail.org, 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: Fri, 21 Dec 2012 02:04:03 -0000\r
+\r
+Quoth david@tethera.net on Dec 16 at 11:24 pm:\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
+\r
+This isn't safe. If the string at ptr is actually shorter than len,\r
+this may read past allocated memory and crash.\r
+\r
+Maybe this should just call talloc_strndup and talloc_set_name_const?\r
+\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
+I agree with Tomi that these shouldn't be named with 'x'. For this\r
+one, it seems fine to simply drop the 'x', since the name is fully\r
+descriptive of what it does.\r
+\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
+For this, what about talloc_strndup_debug?\r
+\r
+> +\r
+> +#endif\r