]> git.notmuchmail.org Git - notmuch/blobdiff - util/talloc-extra.c
util: add talloc-extra.[ch]
[notmuch] / util / talloc-extra.c
diff --git a/util/talloc-extra.c b/util/talloc-extra.c
new file mode 100644 (file)
index 0000000..9626247
--- /dev/null
@@ -0,0 +1,14 @@
+#include <string.h>
+#include "talloc-extra.h"
+
+char *
+talloc_strndup_named_const (void *ctx, const char *str,
+                           size_t len, const char *name)
+{
+    char *ptr = talloc_strndup (ctx, str, len);
+
+    if (ptr)
+       talloc_set_name_const (ptr, name);
+
+    return ptr;
+}