Add a new k5_buf method to make room in the buffer for the caller to
fill in.
#endif
;
+/* Extend the length of buf by len and return a pointer to the reserved space,
+ * to be filled in by the caller. Return NULL on error. */
+void *k5_buf_get_space(struct k5buf *buf, size_t len);
+
/* Truncate BUF. LEN must be between 0 and the existing buffer
* length, or an assertion failure will result. */
void k5_buf_truncate(struct k5buf *buf, size_t len);
free(tmp);
}
+void *
+k5_buf_get_space(struct k5buf *buf, size_t len)
+{
+ if (!ensure_space(buf, len))
+ return NULL;
+ buf->len += len;
+ buf->data[buf->len] = '\0';
+ return &buf->data[buf->len - len];
+}
+
void
k5_buf_truncate(struct k5buf *buf, size_t len)
{
k5_buf_add
k5_buf_add_len
k5_buf_add_fmt
+k5_buf_get_space
k5_buf_truncate
k5_buf_data
k5_buf_len