Reference

rbuf_auto(3)

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

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_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(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)

History