Buffer

Overview

The Buffer module can be thought as the dual of the String module for generic data buffers. The exposed primitives provide hooks for the typical life-cycle of a data buffer: ex-nihil creation or loading from external source, manipulation, possible data printing, raw data extraction and/or dump to non-volatile storage, and disposal.

Typedefs

The basic buffer type. Internally it hides the data buffer which can be accessed via u_buf_ptr, and related size indicators (both total u_malloc'd buffer size, and the number of actually used bytes) which are accessed via u_buf_size and u_buf_len respectively.

Give up ownership of the data block of the supplied u_buf_t object ubuf. Note that u_free won't be called on it, so the caller must u_free the buffer later on. Before calling u_buf_detach, use u_buf_ptr to get the pointer of the data block, and possibly u_buf_size and u_buf_len to get its total size and actually used length.

Create a NUL-terminated string from the printf(3) like arguments and append it to the given u_buf_t object. The length of the appended string (NOT including the ending \0) will be added to the current length of the buffer (u_buf_len).