69 if (segment == NULL) {
78 if (segment == NULL) {
87 if (segment == NULL) {
99 rc = (textbuf->
ocs != NULL);
107 ocs_memset(textbuf, 0,
sizeof(*textbuf));
134 segment = ocs_malloc(textbuf->
ocs,
sizeof(*segment),
135 OCS_M_ZERO | OCS_M_NOWAIT | OCS_M_NONUMA);
136 if (segment != NULL) {
138 OCS_M_ZERO | OCS_M_NOWAIT | OCS_M_NONUMA);
139 if (segment->
buffer != NULL) {
167 ocs_free(ocs, segment,
sizeof(*segment));
195 ocs_memset(textbuf, 0,
sizeof(*textbuf));
199 segment = ocs_malloc(ocs,
sizeof(*segment), OCS_M_ZERO | OCS_M_NOWAIT);
224 ocs_memset(textbuf, 0,
sizeof(*textbuf));
247 ocs_vsnprintf(valuebuf,
sizeof(valuebuf), fmt, ap);
248 ocs_log_info(NULL,
"%s", valuebuf);
265 va_copy(save_ap, ap);
281 if (written >= avail) {
292 ocs_log_err(textbuf->
ocs,
"alloc segment failed\n");
static int32_t ocs_segment_remaining(ocs_textbuf_segment_t *segment)
int32_t ocs_textbuf_get_length(ocs_textbuf_t *textbuf)
int32_t ocs_textbuf_ext_get_length(ocs_textbuf_t *textbuf, uint32_t idx)
int32_t ocs_textbuf_ext_get_written(ocs_textbuf_t *textbuf, uint32_t idx)
void ocs_textbuf_copy(ocs_textbuf_t *textbuf, uint8_t *buffer, uint32_t buffer_length)
static void * ocs_list_get_head(ocs_list_t *list)
Return the first item in the list.
int32_t ocs_textbuf_remaining(ocs_textbuf_t *textbuf)
int32_t ocs_textbuf_get_written(ocs_textbuf_t *textbuf)
uint8_t * ocs_textbuf_get_buffer(ocs_textbuf_t *textbuf)
static ocs_textbuf_segment_t * ocs_textbuf_get_segment(ocs_textbuf_t *textbuf, uint32_t idx)
void ocs_textbuf_free(ocs_t *ocs, ocs_textbuf_t *textbuf)
static void * ocs_list_remove(ocs_list_t *list, void *item)
Remove an item from the list.
static void * ocs_list_get_tail(ocs_list_t *list)
Return the first item in the list.
#define ocs_list_init(head, type, link)
#define OCS_TEXTBUF_MAX_ALLOC_LEN
static void ocs_textbuf_segment_free(ocs_t *ocs, ocs_textbuf_segment_t *segment)
#define ocs_list_foreach_safe(list, item, nxt)
Iterate a linked list safely.
uint32_t allocation_length
uint8_t * ocs_textbuf_ext_get_buffer(ocs_textbuf_t *textbuf, uint32_t idx)
const char const char va_list ap
int32_t ocs_textbuf_init(ocs_t *ocs, ocs_textbuf_t *textbuf, void *buffer, uint32_t length)
void ocs_textbuf_puts(ocs_textbuf_t *textbuf, char *s)
uint32_t total_allocation_length
static void ocs_list_add_tail(ocs_list_t *list, void *item)
Add an item to the tail of the list.
static ocs_textbuf_segment_t * ocs_textbuf_segment_alloc(ocs_textbuf_t *textbuf)
void ocs_textbuf_vprintf(ocs_textbuf_t *textbuf, const char *fmt, va_list ap)
void ocs_textbuf_printf(ocs_textbuf_t *textbuf, const char *fmt,...)
Helper function to dump message.
void ocs_textbuf_putc(ocs_textbuf_t *textbuf, uint8_t c)
void ocs_textbuf_buffer(ocs_textbuf_t *textbuf, uint8_t *buffer, uint32_t buffer_length)
void ocs_textbuf_reset(ocs_textbuf_t *textbuf)
int32_t ocs_textbuf_alloc(ocs_t *ocs, ocs_textbuf_t *textbuf, uint32_t length)
uint32_t ocs_textbuf_initialized(ocs_textbuf_t *textbuf)
#define ocs_list_foreach(list, item)
Iterate a linked list.
const char const char * fmt
uint32_t max_allocation_length