X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Frfc822%2Ftest%2Ftestdata.h;h=ada262b5f544300653a301f566785e1fcaa6011b;hp=f6dff03d61eb021bce50a470ffcce96dbd35c894;hb=e4b6a262822484244b52c476d1b4cc9c4fd8ee2b;hpb=97d99004bec31012400b6c1d9bad045ae1c9b075;ds=sidebyside diff --git a/ccan/rfc822/test/testdata.h b/ccan/rfc822/test/testdata.h index f6dff03d..ada262b5 100644 --- a/ccan/rfc822/test/testdata.h +++ b/ccan/rfc822/test/testdata.h @@ -1,7 +1,7 @@ #ifndef RFC822_TESTDATA_H #define RFC822_TESTDATA_H -#include +#include #include #include @@ -127,30 +127,26 @@ static inline const char *assemble_msg(const struct aexample *e, { const char *nl = crlf ? "\r\n" : "\n"; int nln = crlf ? 2 : 1; - char *msg, *amsg; + char *msg; size_t n = 0; int i; - msg = talloc_strdup(NULL, ""); + msg = tal_strdup(NULL, ""); if (!msg) return NULL; for (i = 0; i < e->nhdrs; i++) { - amsg = talloc_asprintf_append(msg, "%s:%s%s", e->hdrs[i].name, - e->hdrs[i].val, nl); - if (!amsg) { - talloc_free(msg); + if (!tal_append_fmt(&msg, "%s:%s%s", e->hdrs[i].name, + e->hdrs[i].val, nl)) { + tal_free(msg); return NULL; } - msg = amsg; n += strlen(e->hdrs[i].name) + strlen(e->hdrs[i].val) + 1 + nln; } - amsg = talloc_asprintf_append(msg, "%s%s", nl, e->body); - if (!amsg) { - talloc_free(msg); + if (!tal_append_fmt(&msg, "%s%s", nl, e->body)) { + tal_free(msg); return NULL; } - msg = amsg; n += strlen(e->body) + nln; *len = n; return msg;