man rbuf_auto (Fonctions bibliothèques) - create a volatile rbuf from static string

NAME

rbuf_auto - create a volatile rbuf from static string

SYNOPSIS

#include <roy.h>

RBuf * rbuf_auto (char *str);

DESCRIPTION

Create an rbuf from str without the overhead of allocating a new rbuf struct. This call is very similar to rbuf_new_with_static(3) except the returned rbuf comes from a small pool of statically allocated rbufs. Never use rbuf_auto(3) to create long-term rbufs because of the volatility of the static rbuf pool.

RETURN VALUE

A call to rbuf_auto(3) returns a highly volatile rbuf. The programmer doesn't need to call rbuf_free(3) to free the rbuf, and any attempt to free the rbuf will be ignored. The returned rbuf is marked read-only; see rbuf_rdonly(3) for more details. It is also marked as owned; see rbuf_own(3).

ERRORS

This call does not error.

FUNCTION

The rbuf_auto(3) call is implmented using a function.

WARNING

No error checking is done by rbuf_auto(3) to see if there are too many outstanding references to automatic rbufs. If the programer has a reference to an automatic rbuf after a sufficant number of subsequent calls to rbuf_auto(3) the reference held by the programmer will point to a some other static string. By default an automatic rbuf is recycled after 32 calls to rbuf_auto(3), so try never to call rbuf_auto(3) in loops or recursive functions.

SEE ALSO