| 37 | }; |
| 38 | |
| 39 | strbuf *strbuf_new(void) |
| 40 | { |
| 41 | strbuf *buf = malloc(sizeof(strbuf)); |
| 42 | if (buf == 0) { |
| 43 | logmsg(LOGMSG_FATAL, "%s: memory allocation failed\n", __func__); |
| 44 | abort(); |
| 45 | } |
| 46 | buf->buf = malloc(STRBUF_INC); |
| 47 | if (buf->buf == 0) { |
| 48 | logmsg(LOGMSG_FATAL, "%s: memory allocation failed\n", __func__); |
| 49 | abort(); |
| 50 | } |
| 51 | buf->buf[0] = '\0'; |
| 52 | buf->alloc = STRBUF_INC; |
| 53 | buf->len = 0; |
| 54 | return buf; |
| 55 | } |
| 56 | |
| 57 | void strbuf_append(strbuf *buf, const char *str) |
| 58 | { |
no test coverage detected