X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Frfc822%2Frfc822.c;h=636d29a612c2c4b189af9f0fc50cfb7ad4957643;hb=58c5a3524737ec1f6500dd766f717e2f158fc5c0;hp=7f9442a8d04d235908abfd8c15e32520d97acd0f;hpb=127c7534fc4aaa9499c552fdd3e4e9e56c16ca40;p=ccan diff --git a/ccan/rfc822/rfc822.c b/ccan/rfc822/rfc822.c index 7f9442a8..636d29a6 100644 --- a/ccan/rfc822/rfc822.c +++ b/ccan/rfc822/rfc822.c @@ -5,27 +5,16 @@ #include #include -#include #include +#include +#include #include -#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 +#else +#include #endif static void (*allocation_failure_hook)(const char *); @@ -92,6 +81,8 @@ struct rfc822_msg *rfc822_check(const struct rfc822_msg *msg, assert(msg); if (!list_check(&msg->headers, abortstr)) return NULL; + if (!tal_check(msg, abortstr)) + return NULL; return (struct rfc822_msg *)msg; } @@ -106,7 +97,7 @@ struct rfc822_msg *rfc822_start(const void *ctx, const char *p, size_t len) 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; @@ -128,7 +119,7 @@ struct rfc822_msg *rfc822_start(const void *ctx, const char *p, size_t len) 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, @@ -200,7 +191,7 @@ static struct rfc822_header *next_header_parse(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); @@ -354,7 +345,7 @@ struct bytestring rfc822_header_unfolded_value(struct rfc822_msg *msg, 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); @@ -447,7 +438,7 @@ static struct rfc822_header *index_header(struct rfc822_msg *msg, 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;