Lines Matching refs:base
24 struct cbb_buffer_st *base; in cbb_init() local
26 base = OPENSSL_malloc(sizeof(struct cbb_buffer_st)); in cbb_init()
27 if (base == NULL) { in cbb_init()
31 base->buf = buf; in cbb_init()
32 base->len = 0; in cbb_init()
33 base->cap = cap; in cbb_init()
34 base->can_resize = 1; in cbb_init()
37 cbb->base = base; in cbb_init()
63 cbb->base->can_resize = 0; in CBB_init_fixed()
68 if (cbb->base) { in CBB_cleanup()
69 if (cbb->base->can_resize) { in CBB_cleanup()
70 OPENSSL_free(cbb->base->buf); in CBB_cleanup()
72 OPENSSL_free(cbb->base); in CBB_cleanup()
74 cbb->base = NULL; in CBB_cleanup()
77 static int cbb_buffer_add(struct cbb_buffer_st *base, uint8_t **out, in cbb_buffer_add() argument
81 if (base == NULL) { in cbb_buffer_add()
85 newlen = base->len + len; in cbb_buffer_add()
86 if (newlen < base->len) { in cbb_buffer_add()
91 if (newlen > base->cap) { in cbb_buffer_add()
92 size_t newcap = base->cap * 2; in cbb_buffer_add()
95 if (!base->can_resize) { in cbb_buffer_add()
99 if (newcap < base->cap || newcap < newlen) { in cbb_buffer_add()
102 newbuf = OPENSSL_realloc(base->buf, newcap); in cbb_buffer_add()
107 base->buf = newbuf; in cbb_buffer_add()
108 base->cap = newcap; in cbb_buffer_add()
112 *out = base->buf + base->len; in cbb_buffer_add()
114 base->len = newlen; in cbb_buffer_add()
118 static int cbb_buffer_add_u(struct cbb_buffer_st *base, uint32_t v, in cbb_buffer_add_u() argument
126 if (!cbb_buffer_add(base, &buf, len_len)) { in cbb_buffer_add_u()
146 if (cbb->base->can_resize && (out_data == NULL || out_len == NULL)) { in CBB_finish()
152 *out_data = cbb->base->buf; in CBB_finish()
155 *out_len = cbb->base->len; in CBB_finish()
157 cbb->base->buf = NULL; in CBB_finish()
168 if (cbb->base == NULL) { in CBB_flush()
180 cbb->base->len < child_start) { in CBB_flush()
184 len = cbb->base->len - child_start; in CBB_flush()
219 if (!cbb_buffer_add(cbb->base, NULL, extra_bytes)) { in CBB_flush()
222 memmove(cbb->base->buf + child_start + extra_bytes, in CBB_flush()
223 cbb->base->buf + child_start, len); in CBB_flush()
225 cbb->base->buf[cbb->offset++] = initial_length_byte; in CBB_flush()
230 cbb->base->buf[cbb->offset + i] = len; in CBB_flush()
237 cbb->child->base = NULL; in CBB_flush()
255 cbb->offset = cbb->base->len; in cbb_add_length_prefixed()
256 if (!cbb_buffer_add(cbb->base, &prefix_bytes, len_len)) { in cbb_add_length_prefixed()
262 out_contents->base = cbb->base; in cbb_add_length_prefixed()
293 cbb->offset = cbb->base->len; in CBB_add_asn1()
299 out_contents->base = cbb->base; in CBB_add_asn1()
311 !cbb_buffer_add(cbb->base, &dest, len)) { in CBB_add_bytes()
320 !cbb_buffer_add(cbb->base, out_data, len)) { in CBB_add_space()
331 return cbb_buffer_add_u(cbb->base, value, 1); in CBB_add_u8()
339 return cbb_buffer_add_u(cbb->base, value, 2); in CBB_add_u16()
347 return cbb_buffer_add_u(cbb->base, value, 3); in CBB_add_u24()