return copysize;
}
+size_t ringbuf_copy(struct ringbuf *to, struct ringbuf *from, size_t size)
+{
+ size_t tocopy = MIN(ringbuf_space(to), size);
+ uint8_t *cbuf = XCALLOC(MTYPE_TMP, tocopy);
+ tocopy = ringbuf_peek(from, 0, cbuf, tocopy);
+ XFREE(MTYPE_TMP, cbuf);
+ return ringbuf_put(to, cbuf, tocopy);
+}
+
void ringbuf_reset(struct ringbuf *buf)
{
buf->start = buf->end = 0;
size_t ringbuf_peek(struct ringbuf *buf, size_t offset, void *data,
size_t size);
+/*
+ * Copy data from one ringbuf to another.
+ *
+ * @param to destination ringbuf
+ * @param from source ringbuf
+ * @param size how much data to copy
+ * @return amount of data copied
+ */
+size_t ringbuf_copy(struct ringbuf *to, struct ringbuf *from, size_t size);
+
/*
* Reset buffer. Does not wipe.
*