Ensure strbuf can handle a string length bytes long (ignoring NULL * optional termination). */
| 162 | /* Ensure strbuf can handle a string length bytes long (ignoring NULL |
| 163 | * optional termination). */ |
| 164 | void strbuf_resize(strbuf_t *s, int len) |
| 165 | { |
| 166 | int newsize; |
| 167 | |
| 168 | newsize = calculate_new_size(s, len); |
| 169 | |
| 170 | if (s->debug > 1) { |
| 171 | fprintf(stderr, "strbuf(%lx) resize: %d => %d\n", |
| 172 | (long)s, s->size, newsize); |
| 173 | } |
| 174 | |
| 175 | s->size = newsize; |
| 176 | s->buf = realloc(s->buf, s->size); |
| 177 | if (!s->buf) |
| 178 | die("Out of memory"); |
| 179 | s->reallocs++; |
| 180 | } |
| 181 | |
| 182 | void strbuf_append_string(strbuf_t *s, const char *str) |
| 183 | { |
no test coverage detected