man rbuf_new (Fonctions bibliothèques) - the rbuf allocation api
NAME
rbuf_new - the rbuf allocation api
SYNOPSIS
#include <roy.h>
RBuf * rbuf_new (void);
RBuf * rbuf_new_sized (unsigned int len);
RBuf * rbuf_new_with_str (const char *str);
RBuf * rbuf_new_with_long (const long int val);
RBuf * rbuf_new_with_float (const float val);
RBuf * rbuf_new_with_static (char *str);
RBuf * rbuf_new_with_sprintf (const char *format, ...);
RBuf * rbuf_new_with_data (const char *str, unsigned int len);
RBuf * rbuf_new_with_rbuf (const RBuf *buf);
DESCRIPTION
All these calls except rbuf_new_with_static(3) create copies of the passed in initialiation data. For the calls that make copies you can free the initialiation data or the rbuf without side-effect.
A call to rbuf_new(3) creates a new rbuf that is empty.
A call to rbuf_new_sized(3) creates a new rbuf which is len bytes long with the buffer set to all '\0's.
A call to rbuf_new_with_str(3) creates a new rbuf that starts with the buffer equal to str.
A call to rbuf_new_with_long(3) creates a new rbuf using the ascii representation of val.
A call to rbuf_new_with_float(3) creates a new rbuf using the ascii representation of val.
A call to rbuf_new_with_static(3) creates a new rbuf with the str, but does not copy str out, instead, it just keeps a pointer to the string you passed in. The returned rbuf is permanatly set read-only regardless of any other api calls made on the rbuf. No attempt is ever made to free the passed in string. The programmer still needs to free the returned rbuf. See rbuf_auto(3) if you are interested in reducing performance impact even farther. The returned rbuf is marked read-only; see rbuf_rdonly(3) for more details.
A call to ruf_new_with_sprintf(3) creates a new rbuf with the formatted string and arguments in the buffer. The size of the rbuf will automatically expand to contain the length of the formatted string, so there is no worry about overflowing any buffers.
A call to rbuf_new_with_data(3) creates a new rbuf which is len bytes long with the buffer memcpy(3)'ed from str.
A call to rbuf_new_with_rbuf(3) creates a new rbuf that is a full clone of buf.
RETURN VALUE
Each of these api calls return an rbuf struct for use with other rbuf calls. The programmer should free the return value of these calls with a call to rbuf_free(3) when he/she is done using the rbuf.
ERRORS
These calls do not error.
FUNCTION
SEE ALSO
rbuf(3), rbuf_append(3), rbuf_append_char(3), rbuf_append_data(3), rbuf_append_rbuf(3), rbuf_append_sprintf(3), rbuf_append_str(3), rbuf_append_vsprintf(3), rbuf_auto(3), rbuf_down(3), rbuf_empty(3), rbuf_equal(3), rbuf_equal_data(3), rbuf_equal_rbuf(3), rbuf_equal_rbuf_len(3), rbuf_equal_rbufcase(3), rbuf_equal_str(3), rbuf_equal_str_len(3), rbuf_equal_strcase(3), rbuf_erase(3), rbuf_float(3), rbuf_free(3), rbuf_hash(3), rbuf_insert(3), rbuf_last(3), rbuf_len(3), rbuf_long(3), rbuf_new_with_sprintf(3), rbuf_own(3), rbuf_prepend(3), rbuf_prepend_char(3), rbuf_prepend_data(3), rbuf_prepend_rbuf(3), rbuf_prepend_str(3), rbuf_rdonly(3), rbuf_set_to(3), rbuf_split(3), rbuf_sprintf(3), rbuf_str(3), rbuf_truncate(3), rbuf_up(3), roy(3)