#include <string.h>
#include <ccan/str/str.h>
-#include <ccan/talloc/talloc.h>
#include <ccan/list/list.h>
+#include <stdio.h>
+#include <ccan/mem/mem.h>
#include <ccan/rfc822/rfc822.h>
-#if !HAVE_MEMMEM
-void *memmem(const void *haystack, size_t haystacklen,
- const void *needle, size_t needlelen)
-{
- const char *p, *last;
-
- p = haystack;
- last = p + haystacklen - needlelen;
-
- do {
- if (memcmp(p, needle, needlelen) == 0)
- return (void *)p;
- } while (p++ <= last);
-
- return NULL;
-}
+#ifdef TAL_USE_TALLOC
+#include <ccan/tal/talloc/talloc.h>
+#else
+#include <ccan/tal/tal.h>
#endif
static void (*allocation_failure_hook)(const char *);
assert(msg);
if (!list_check(&msg->headers, abortstr))
return NULL;
+ if (!tal_check(msg, abortstr))
+ return NULL;
return (struct rfc822_msg *)msg;
}
struct rfc822_msg *msg;
int i;
- msg = talloc(ctx, struct rfc822_msg);
+ msg = tal(ctx, struct rfc822_msg);
ALLOC_CHECK(msg, NULL);
msg->data = p;
void rfc822_free(struct rfc822_msg *msg)
{
CHECK(msg, ">rfc822_free");
- talloc_free(msg);
+ tal_free(msg);
}
static struct rfc822_header *next_header_cached(struct rfc822_msg *msg,
msg->remainder = eh;
- hi = talloc_zero(msg, struct rfc822_header);
+ hi = talz(msg, struct rfc822_header);
ALLOC_CHECK(hi, NULL);
hi->all = bytestring(h, eh - h);
if (lines <= 1) {
hdr->unfolded = bytestring(raw.ptr, len);
} else {
- char *unfold = talloc_array(msg, char, len);
+ char *unfold = tal_arr(msg, char, len);
char *p = unfold;
ALLOC_CHECK(unfold, bytestring_NULL);
if (!hn) {
unsigned hash = headerhash(hname);
- hn = talloc_zero(msg, struct rfc822_headers_of_name);
+ hn = talz(msg, struct rfc822_headers_of_name);
ALLOC_CHECK(hn, NULL);
hn->name = hname;