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

All rbuf_new(3) style api calls are implemented using functions.

SEE ALSO