15 error("can't malloc: %r");
21 erealloc(void *p, ulong n)
25 error("can't malloc: %r");
34 t = emalloc(strlen(s)+1);
40 estrstrdup(char *s, char *t)
47 /* use malloc to avoid memset */
50 error("can't malloc: %r");
58 eappend(char *s, char *sep, char *t)
64 u = estrstrdup(s, sep);
69 /* use malloc to avoid memset */
70 u = malloc(ns+nsep+nt+1);
72 error("can't malloc: %r");
74 memmove(u+ns, sep, nsep);
75 memmove(u+ns+nsep, t, nt);
83 egrow(char *s, char *sep, char *t)
85 s = eappend(s, sep, t);
97 fmtfdinit(&f, 2, buf, sizeof buf);
98 fmtprint(&f, "Mail: ");
100 fmtvprint(&f, fmt, arg);
108 growbytes(Bytes *b, char *s, long ns)
110 if(b->nalloc < b->n + ns + 1){
111 b->nalloc = b->n + ns + 8000;
112 /* use realloc to avoid memset */
113 b->b = realloc(b->b, b->nalloc);
115 error("growbytes: can't realloc: %r");
117 memmove(b->b+b->n, s, ns);