Lines Matching refs:base

29   struct cbb_buffer_st *base;  in cbb_init()  local
31 base = OPENSSL_malloc(sizeof(struct cbb_buffer_st)); in cbb_init()
32 if (base == NULL) { in cbb_init()
36 base->buf = buf; in cbb_init()
37 base->len = 0; in cbb_init()
38 base->cap = cap; in cbb_init()
39 base->can_resize = 1; in cbb_init()
41 cbb->base = base; in cbb_init()
69 cbb->base->can_resize = 0; in CBB_init_fixed()
74 if (cbb->base) { in CBB_cleanup()
79 if (cbb->base->can_resize) { in CBB_cleanup()
80 OPENSSL_free(cbb->base->buf); in CBB_cleanup()
82 OPENSSL_free(cbb->base); in CBB_cleanup()
84 cbb->base = NULL; in CBB_cleanup()
87 static int cbb_buffer_reserve(struct cbb_buffer_st *base, uint8_t **out, in cbb_buffer_reserve() argument
91 if (base == NULL) { in cbb_buffer_reserve()
95 newlen = base->len + len; in cbb_buffer_reserve()
96 if (newlen < base->len) { in cbb_buffer_reserve()
101 if (newlen > base->cap) { in cbb_buffer_reserve()
102 size_t newcap = base->cap * 2; in cbb_buffer_reserve()
105 if (!base->can_resize) { in cbb_buffer_reserve()
109 if (newcap < base->cap || newcap < newlen) { in cbb_buffer_reserve()
112 newbuf = OPENSSL_realloc(base->buf, newcap); in cbb_buffer_reserve()
117 base->buf = newbuf; in cbb_buffer_reserve()
118 base->cap = newcap; in cbb_buffer_reserve()
122 *out = base->buf + base->len; in cbb_buffer_reserve()
128 static int cbb_buffer_add(struct cbb_buffer_st *base, uint8_t **out, in cbb_buffer_add() argument
130 if (!cbb_buffer_reserve(base, out, len)) { in cbb_buffer_add()
134 base->len += len; in cbb_buffer_add()
138 static int cbb_buffer_add_u(struct cbb_buffer_st *base, uint32_t v, in cbb_buffer_add_u() argument
146 if (!cbb_buffer_add(base, &buf, len_len)) { in cbb_buffer_add_u()
166 if (cbb->base->can_resize && (out_data == NULL || out_len == NULL)) { in CBB_finish()
172 *out_data = cbb->base->buf; in CBB_finish()
175 *out_len = cbb->base->len; in CBB_finish()
177 cbb->base->buf = NULL; in CBB_finish()
188 if (cbb->base == NULL) { in CBB_flush()
200 cbb->base->len < child_start) { in CBB_flush()
204 len = cbb->base->len - child_start; in CBB_flush()
239 if (!cbb_buffer_add(cbb->base, NULL, extra_bytes)) { in CBB_flush()
242 memmove(cbb->base->buf + child_start + extra_bytes, in CBB_flush()
243 cbb->base->buf + child_start, len); in CBB_flush()
245 cbb->base->buf[cbb->child->offset++] = initial_length_byte; in CBB_flush()
251 cbb->base->buf[cbb->child->offset + i] = len; in CBB_flush()
258 cbb->child->base = NULL; in CBB_flush()
266 return cbb->base->buf + cbb->offset + cbb->pending_len_len; in CBB_data()
271 assert(cbb->offset + cbb->pending_len_len <= cbb->base->len); in CBB_len()
273 return cbb->base->len - cbb->offset - cbb->pending_len_len; in CBB_len()
284 size_t offset = cbb->base->len; in cbb_add_length_prefixed()
285 if (!cbb_buffer_add(cbb->base, &prefix_bytes, len_len)) { in cbb_add_length_prefixed()
291 out_contents->base = cbb->base; in cbb_add_length_prefixed()
323 size_t offset = cbb->base->len; in CBB_add_asn1()
329 out_contents->base = cbb->base; in CBB_add_asn1()
342 !cbb_buffer_add(cbb->base, &dest, len)) { in CBB_add_bytes()
351 !cbb_buffer_add(cbb->base, out_data, len)) { in CBB_add_space()
359 !cbb_buffer_reserve(cbb->base, out_data, len)) { in CBB_reserve()
366 size_t newlen = cbb->base->len + len; in CBB_did_write()
368 newlen < cbb->base->len || in CBB_did_write()
369 newlen > cbb->base->cap) { in CBB_did_write()
372 cbb->base->len = newlen; in CBB_did_write()
381 return cbb_buffer_add_u(cbb->base, value, 1); in CBB_add_u8()
389 return cbb_buffer_add_u(cbb->base, value, 2); in CBB_add_u16()
397 return cbb_buffer_add_u(cbb->base, value, 3); in CBB_add_u24()
405 cbb->base->len = cbb->child->offset; in CBB_discard_child()
407 cbb->child->base = NULL; in CBB_discard_child()