| 120 | } |
| 121 | |
| 122 | int reftable_buf_add(struct reftable_buf *buf, const void *data, size_t len) |
| 123 | { |
| 124 | size_t newlen = buf->len + len; |
| 125 | |
| 126 | if (newlen + 1 > buf->alloc) { |
| 127 | if (REFTABLE_ALLOC_GROW(buf->buf, newlen + 1, buf->alloc)) |
| 128 | return REFTABLE_OUT_OF_MEMORY_ERROR; |
| 129 | } |
| 130 | |
| 131 | memcpy(buf->buf + buf->len, data, len); |
| 132 | buf->buf[newlen] = '\0'; |
| 133 | buf->len = newlen; |
| 134 | |
| 135 | return 0; |
| 136 | } |
| 137 | |
| 138 | int reftable_buf_addstr(struct reftable_buf *buf, const char *s) |
| 139 | { |
no outgoing calls