Function rc_ringbuf_alloc#

Function Documentation#

int rc_ringbuf_alloc(rc_ringbuf_t *buf, int size)#

Allocates memory for a ring buffer and initializes an rc_ringbuf_t struct.

If buf is already the right size then it is left untouched. Otherwise any existing memory allocated for buf is freed to avoid memory leaks and new memory is allocated.

Parameters:
  • buf – Pointer to user’s buffer

  • size[in] Number of elements to allocate space for

Returns:

Returns 0 on success or -1 on failure.