}
}
+void buffer_nul_terminate(buffer_t *_buf)
+{
+ struct real_buffer *buf = container_of(_buf, struct real_buffer, buf);
+
+ /* +1 extra byte is always kept for NUL termination */
+ i_assert(buf->used < buf->alloc);
+ /* Buffer might not be writable, so check first if the NUL is
+ already there. */
+ if (((const char *)buf->r_buffer)[buf->used] != '\0')
+ buf->w_buffer[buf->used] = '\0';
+}
+
void buffer_copy(buffer_t *_dest, size_t dest_pos,
const buffer_t *_src, size_t src_pos, size_t copy_size)
{
void buffer_write_zero(buffer_t *buf, size_t pos, size_t data_size);
void buffer_append_zero(buffer_t *buf, size_t data_size);
void buffer_insert_zero(buffer_t *buf, size_t pos, size_t data_size);
+/* Terminate the buffer with a NUL character after the buffer's used size.
+ The NUL will not be included in the used size. */
+void buffer_nul_terminate(buffer_t *buf);
/* Copy data from buffer to another. The buffers may be same in which case
it's internal copying, possibly with overlapping positions (ie. memmove()