X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/c6f2d14d9c38345075629af3487c2de491584ca1..ef1ba39e8dae81091b6c3e73e72825ef6edea3c6:/uip/fmttest.c diff --git a/uip/fmttest.c b/uip/fmttest.c index b0c869cb..7d08438b 100644 --- a/uip/fmttest.c +++ b/uip/fmttest.c @@ -354,7 +354,7 @@ main (int argc, char **argv) NEW(ctx); ctx->num = -1; ctx->str = dummy; - ctx->outbuf = getcpy(NULL); + ctx->outbuf = mh_xstrdup(""); cb.trace_func = test_trace; cb.trace_context = ctx; @@ -422,8 +422,8 @@ process_addresses(struct format *fmt, struct msgs_array *addrs, while ((cp = getname(addrs->msgs[i]))) { NEW0(p); if ((mp = getm(cp, NULL, 0, error, sizeof(error))) == NULL) { - p->pq_text = getcpy(cp); - p->pq_error = getcpy(error); + p->pq_text = mh_xstrdup(cp); + p->pq_error = mh_xstrdup(error); } else { p->pq_text = getcpy(mp->m_text); mnfree(mp); @@ -434,15 +434,13 @@ process_addresses(struct format *fmt, struct msgs_array *addrs, for (p = pq.pq_next; p; p = q) { c = fmt_findcomp("text"); if (c) { - if (c->c_text) - free(c->c_text); + mh_xfree(c->c_text); c->c_text = p->pq_text; p->pq_text = NULL; } c = fmt_findcomp("error"); if (c) { - if (c->c_text) - free(c->c_text); + mh_xfree(c->c_text); c->c_text = p->pq_error; p->pq_error = NULL; } @@ -451,10 +449,8 @@ process_addresses(struct format *fmt, struct msgs_array *addrs, fputs(charstring_buffer(buffer), stdout); mlistfree(); - if (p->pq_text) - free(p->pq_text); - if (p->pq_error) - free(p->pq_error); + mh_xfree(p->pq_text); + mh_xfree(p->pq_error); q = p->pq_next; free(p); } @@ -529,14 +525,13 @@ process_messages(struct format *fmt, struct msgs_array *comps, if ((cp = context_find(usequence)) && *cp) { char **ap, *dp; - dp = getcpy(cp); + dp = mh_xstrdup(cp); ap = brkstring(dp, " ", "\n"); for (i = 0; ap && *ap; i++, ap++) ivector_push_back (seqnum, seq_getnum(mp, *ap)); num_unseen_seq = i; - if (dp) - free(dp); + mh_xfree(dp); } } @@ -671,8 +666,7 @@ finished: for (i = 0; i < comps->size; i += 2) { c = fmt_findcomp(comps->msgs[i]); if (c) { - if (c->c_text) - free(c->c_text); + mh_xfree(c->c_text); c->c_text = getcpy(comps->msgs[i + 1]); } } @@ -706,8 +700,7 @@ process_raw(struct format *fmt, struct msgs_array *text, charstring_t buffer, for (i = 0; i < text->size; i++) { if (c != NULL) { - if (c->c_text != NULL) - free(c->c_text); + mh_xfree(c->c_text); c->c_text = getcpy(text->msgs[i]); } @@ -741,21 +734,21 @@ test_trace(void *context, struct format *fmt, int num, char *str, if (str != ctx->str) { if (changed++) - printf(" "); + putchar(' '); printf("str="); litputs(str); ctx->str = str; } if (changed) - printf("\n"); + putchar('\n'); if (strcmp(outbuf, ctx->outbuf) != 0) { printf("outbuf="); litputs(outbuf); putchar('\n'); free(ctx->outbuf); - ctx->outbuf = getcpy(outbuf); + ctx->outbuf = mh_xstrdup(outbuf); } }