+/**
+ * Get references to buffers pointing to free space of the buffer pool area.
+ *
+ * \param btrp The buffer pool.
+ * \param iov The scatter array.
+ *
+ * \return Zero if the buffer pool is full, one if the free space of the buffer
+ * pool area is available as a single contiguous buffer, two if the free space
+ * consists of two buffers. If this function returns the value n, then n
+ * elements of \a iov are initialized.
+ */
+int btr_pool_get_buffers(struct btr_pool *btrp, struct iovec iov[2])
+{
+ size_t sz, unused;
+ char *buf;
+
+ sz = btr_pool_get_buffer(btrp, &buf);
+ if (sz == 0)
+ return 0;
+ iov[0].iov_len = sz;
+ iov[0].iov_base = buf;
+ unused = btr_pool_unused(btrp);
+ if (sz == unused)
+ return 1;
+ iov[1].iov_len = unused - sz;
+ iov[1].iov_base = btrp->area_start;
+ return 2;
+}
+
+/**
+ * Mark a part of the buffer pool area as allocated.
+ *
+ * \param btrp The buffer pool.
+ * \param size The amount of bytes to be allocated.
+ *
+ * This is usually called after the caller wrote to the buffer obtained by
+ * btr_pool_get_buffer().
+ */
+static void btr_pool_allocate(struct btr_pool *btrp, size_t size)