Home | History | Annotate | Download | only in bytestring

Lines Matching full:base

31   struct cbb_buffer_st *base;
33 base = OPENSSL_malloc(sizeof(struct cbb_buffer_st));
34 if (base == NULL) {
38 base->buf = buf;
39 base->len = 0;
40 base->cap = cap;
41 base->can_resize = 1;
42 base->error = 0;
44 cbb->base = base;
72 cbb->base->can_resize = 0;
77 if (cbb->base) {
82 if (cbb->base->can_resize) {
83 OPENSSL_free(cbb->base->buf);
85 OPENSSL_free(cbb->base);
87 cbb->base = NULL;
90 static int cbb_buffer_reserve(struct cbb_buffer_st *base, uint8_t **out,
94 if (base == NULL) {
98 newlen = base->len + len;
99 if (newlen < base->len) {
104 if (newlen > base->cap) {
105 size_t newcap = base->cap * 2;
108 if (!base->can_resize) {
112 if (newcap < base->cap || newcap < newlen) {
115 newbuf = OPENSSL_realloc(base->buf, newcap);
120 base->buf = newbuf;
121 base->cap = newcap;
125 *out = base->buf + base->len;
131 base->error = 1;
135 static int cbb_buffer_add(struct cbb_buffer_st *base, uint8_t **out,
137 if (!cbb_buffer_reserve(base, out, len)) {
141 base->len += len;
145 static int cbb_buffer_add_u(struct cbb_buffer_st *base, uint32_t v,
152 if (!cbb_buffer_add(base, &buf, len_len)) {
162 base->error = 1;
178 if (cbb->base->can_resize && (out_data == NULL || out_len == NULL)) {
184 *out_data = cbb->base->buf;
187 *out_len = cbb->base->len;
189 cbb->base->buf = NULL;
195 * current length of the underlying base is taken to be the length of the
200 /* If |cbb->base| has hit an error, the buffer is in an undefined state, so
203 if (cbb->base == NULL || cbb->base->error) {
215 cbb->base->len < child_start) {
219 len = cbb->base->len - child_start;
254 if (!cbb_buffer_add(cbb->base, NULL, extra_bytes)) {
257 OPENSSL_memmove(cbb->base->buf + child_start + extra_bytes,
258 cbb->base->buf + child_start, len);
260 cbb->base->buf[cbb->child->offset++] = initial_length_byte;
266 cbb->base->buf[cbb->child->offset + i] = (uint8_t)len;
273 cbb->child->base = NULL;
279 cbb->base->error = 1;
285 return cbb->base->buf + cbb->offset + cbb->pending_len_len;
290 assert(cbb->offset + cbb->pending_len_len <= cbb->base->len);
292 return cbb->base->len - cbb->offset - cbb->pending_len_len;
303 size_t offset = cbb->base->len;
304 if (!cbb_buffer_add(cbb->base, &prefix_bytes, len_len)) {
310 out_contents->base = cbb->base;
336 cbb->base->error = 1;
346 size_t offset = cbb->base->len;
352 out_contents->base = cbb->base;
365 !cbb_buffer_add(cbb->base, &dest, len)) {
374 !cbb_buffer_add(cbb->base, out_data, len)) {
382 !cbb_buffer_reserve(cbb->base, out_data, len)) {
389 size_t newlen = cbb->base->len + len;
391 newlen < cbb->base->len ||
392 newlen > cbb->base->cap) {
395 cbb->base->len = newlen;
404 return cbb_buffer_add_u(cbb->base, value, 1);
412 return cbb_buffer_add_u(cbb->base, value, 2);
420 return cbb_buffer_add_u(cbb->base, value, 3);
428 return cbb_buffer_add_u(cbb->base, value, 4);
436 cbb->base->len = cbb->child->offset;
438 cbb->child->base = NULL;