| 55 | } |
| 56 | |
| 57 | void strbuf_append(strbuf *buf, const char *str) |
| 58 | { |
| 59 | assert(buf != NULL); |
| 60 | size_t len = strlen(str); |
| 61 | if (buf->alloc < buf->len + len + 1) { |
| 62 | size_t inc = len >= STRBUF_INC ? len + 1 : STRBUF_INC; |
| 63 | buf->alloc += inc; |
| 64 | buf->buf = realloc(buf->buf, buf->alloc); |
| 65 | if (buf->buf == 0) { |
| 66 | logmsg(LOGMSG_FATAL, "%s: memory allocation failed\n", __func__); |
| 67 | abort(); |
| 68 | } |
| 69 | } |
| 70 | strcat(buf->buf, str); |
| 71 | buf->len += len; |
| 72 | } |
| 73 | |
| 74 | const char *strbuf_buf(const strbuf *buf) |
| 75 | { |
no test coverage detected