1#ifndef JEMALLOC_INTERNAL_BUF_WRITER_H
2#define JEMALLOC_INTERNAL_BUF_WRITER_H
3
4/*
5 * Note: when using the buffered writer, cbopaque is passed to write_cb only
6 * when the buffer is flushed. It would make a difference if cbopaque points
7 * to something that's changing for each write_cb call, or something that
8 * affects write_cb in a way dependent on the content of the output string.
9 * However, the most typical usage case in practice is that cbopaque points to
10 * some "option like" content for the write_cb, so it doesn't matter.
11 */
12
13typedef struct {
14 write_cb_t *write_cb;
15 void *cbopaque;
16 char *buf;
17 size_t buf_size;
18 size_t buf_end;
19 bool internal_buf;
20} buf_writer_t;
21
22bool buf_writer_init(tsdn_t *tsdn, buf_writer_t *buf_writer,
23 write_cb_t *write_cb, void *cbopaque, char *buf, size_t buf_len);
24void buf_writer_flush(buf_writer_t *buf_writer);
25write_cb_t buf_writer_cb;
26void buf_writer_terminate(tsdn_t *tsdn, buf_writer_t *buf_writer);
27
28typedef ssize_t (read_cb_t)(void *read_cbopaque, void *buf, size_t limit);
29void buf_writer_pipe(buf_writer_t *buf_writer, read_cb_t *read_cb,
30 void *read_cbopaque);
31
32#endif /* JEMALLOC_INTERNAL_BUF_WRITER_H */
33