Lines Matching full:wbuf
16 * wbuf
19 static int wbuf_flush(struct json_write_buf *wbuf, int full);
21 static int wbuf_init(struct json_write_buf *wbuf, BIO *bio, size_t alloc) in wbuf_init() argument
23 wbuf->buf = OPENSSL_malloc(alloc); in wbuf_init()
24 if (wbuf->buf == NULL) in wbuf_init()
27 wbuf->cur = 0; in wbuf_init()
28 wbuf->alloc = alloc; in wbuf_init()
29 wbuf->bio = bio; in wbuf_init()
33 static void wbuf_cleanup(struct json_write_buf *wbuf) in wbuf_cleanup() argument
35 OPENSSL_free(wbuf->buf); in wbuf_cleanup()
36 wbuf->buf = NULL; in wbuf_cleanup()
37 wbuf->alloc = 0; in wbuf_cleanup()
40 static void wbuf_set0_bio(struct json_write_buf *wbuf, BIO *bio) in wbuf_set0_bio() argument
42 wbuf->bio = bio; in wbuf_set0_bio()
46 static ossl_inline void wbuf_clean(struct json_write_buf *wbuf) in wbuf_clean() argument
48 wbuf->cur = 0; in wbuf_clean()
52 static ossl_inline size_t wbuf_avail(struct json_write_buf *wbuf) in wbuf_avail() argument
54 return wbuf->alloc - wbuf->cur; in wbuf_avail()
58 static ossl_inline int wbuf_write_char(struct json_write_buf *wbuf, char c) in wbuf_write_char() argument
60 if (wbuf_avail(wbuf) == 0) { in wbuf_write_char()
61 if (!wbuf_flush(wbuf, /*full=*/0)) in wbuf_write_char()
65 wbuf->buf[wbuf->cur++] = c; in wbuf_write_char()
72 static int wbuf_write_str(struct json_write_buf *wbuf, const char *s) in wbuf_write_str() argument
77 if (!wbuf_write_char(wbuf, c)) in wbuf_write_str()
84 static int wbuf_flush(struct json_write_buf *wbuf, int full) in wbuf_flush() argument
88 while (total_written < wbuf->cur) { in wbuf_flush()
89 if (!BIO_write_ex(wbuf->bio, in wbuf_flush()
90 wbuf->buf + total_written, in wbuf_flush()
91 wbuf->cur - total_written, in wbuf_flush()
93 memmove(wbuf->buf, in wbuf_flush()
94 wbuf->buf + total_written, in wbuf_flush()
95 wbuf->cur - total_written); in wbuf_flush()
96 wbuf->cur = 0; in wbuf_flush()
103 wbuf->cur = 0; in wbuf_flush()
106 (void)BIO_flush(wbuf->bio); /* best effort */ in wbuf_flush()
241 if (!wbuf_init(&json->wbuf, bio, 4096)) in ossl_json_init()
250 wbuf_cleanup(&json->wbuf); in ossl_json_cleanup()
268 wbuf_clean(&json->wbuf); in ossl_json_reset()
277 return wbuf_flush(&json->wbuf, /*full=*/1); in ossl_json_flush()
282 wbuf_set0_bio(&json->wbuf, bio); in ossl_json_set0_sink()
318 if (!wbuf_write_char(&json->wbuf, ch)) in json_write_char()
328 if (!wbuf_write_str(&json->wbuf, s)) in json_write_str()