rb_discard

NAME

rb_clear(3), rb_discard(3) - remove data from buffer without performing any read or copying

SYNOPSIS

#include <rb.h>

int rb_clear(struct rb *rb, int clear);
long rb_discard(struct rb *rb, size_t count);

DESCRIPTION

rb_discard(3) will remove count elements from rb ring buffer. This basically acts the same way as rb_recv(3) but does not perform any copies and can never block.

rb_clear(3) will clear out whole ring buffer. If clear is set to 1, function will also zero-out all buffer, which may be good if you want to remove some confidential data from memory.

When multi-thread is enabled, rb_clear(3) will block to acquire read mutex, and if clear is set it may also wake up threads blocked in write. These woken threads may return EAGAIN errors during the clear operation.

SEE ALSO

rb_new(3), rb_init(3), rb_destroy(3), rb_cleanup(3), rb_write(3), rb_send(3), rb_writev(3), rb_sendv(3), rb_read(3), rb_recv(3), rb_readv(3), rb_recvv(3), rb_read_claim(3), rb_read_commit(3), rb_write_claim(3), rb_write_commit(3), rb_clear(3), rb_discard(3), rb_count(3), rb_space(3), rb_stop(3), rb_peek_size(3), rb_set_hard_max_count(3)