提交 c6914fda 编写于 作者: J jp9000

libobs/util: Add circlebuf_push_front function

上级 5be855e8
......@@ -168,6 +168,27 @@ static inline void circlebuf_push_back(struct circlebuf *cb, const void *data,
cb->end_pos = new_end_pos;
}
static inline void circlebuf_push_front(struct circlebuf *cb, const void *data,
size_t size)
{
cb->size += size;
circlebuf_ensure_capacity(cb);
if (cb->start_pos < size) {
size_t back_size = size - cb->start_pos;
if (cb->start_pos)
memcpy(cb->data, (uint8_t*)data + back_size,
cb->start_pos);
cb->start_pos = cb->capacity - back_size;
memcpy((uint8_t*)cb->data + cb->start_pos, data, back_size);
} else {
cb->start_pos -= size;
memcpy((uint8_t*)cb->data + cb->start_pos, data, size);
}
}
static inline void circlebuf_peek_front(struct circlebuf *cb, void *data,
size_t size)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册