|
197 | 197 | */
|
198 | 198 | void cbor_encoder_init(CborEncoder *encoder, uint8_t *buffer, size_t size, int flags)
|
199 | 199 | {
|
200 |
| - encoder->data.ptr = buffer; |
| 200 | + encoder->ptr = buffer; |
201 | 201 | encoder->end = buffer + size;
|
202 | 202 | encoder->added = 0;
|
203 | 203 | encoder->flags = flags;
|
@@ -235,34 +235,34 @@ static inline void put64(void *where, uint64_t v)
|
235 | 235 | static inline bool would_overflow(CborEncoder *encoder, size_t len)
|
236 | 236 | {
|
237 | 237 | ptrdiff_t remaining = (ptrdiff_t)encoder->end;
|
238 |
| - remaining -= remaining ? (ptrdiff_t)encoder->data.ptr : encoder->data.bytes_needed; |
| 238 | + remaining -= remaining ? (ptrdiff_t)encoder->ptr : encoder->bytes_needed; |
239 | 239 | remaining -= (ptrdiff_t)len;
|
240 | 240 | return unlikely(remaining < 0);
|
241 | 241 | }
|
242 | 242 |
|
243 | 243 | static inline void advance_ptr(CborEncoder *encoder, size_t n)
|
244 | 244 | {
|
245 | 245 | if (encoder->end)
|
246 |
| - encoder->data.ptr += n; |
| 246 | + encoder->ptr += n; |
247 | 247 | else
|
248 |
| - encoder->data.bytes_needed += n; |
| 248 | + encoder->bytes_needed += n; |
249 | 249 | }
|
250 | 250 |
|
251 | 251 | static inline CborError append_to_buffer(CborEncoder *encoder, const void *data, size_t len)
|
252 | 252 | {
|
253 | 253 | if (would_overflow(encoder, len)) {
|
254 | 254 | if (encoder->end != NULL) {
|
255 |
| - len -= encoder->end - encoder->data.ptr; |
| 255 | + len -= encoder->end - encoder->ptr; |
256 | 256 | encoder->end = NULL;
|
257 |
| - encoder->data.bytes_needed = 0; |
| 257 | + encoder->bytes_needed = 0; |
258 | 258 | }
|
259 | 259 |
|
260 | 260 | advance_ptr(encoder, len);
|
261 | 261 | return CborErrorOutOfMemory;
|
262 | 262 | }
|
263 | 263 |
|
264 |
| - memcpy(encoder->data.ptr, data, len); |
265 |
| - encoder->data.ptr += len; |
| 264 | + memcpy(encoder->ptr, data, len); |
| 265 | + encoder->ptr += len; |
266 | 266 | return CborNoError;
|
267 | 267 | }
|
268 | 268 |
|
@@ -447,7 +447,7 @@ __attribute__((noinline))
|
447 | 447 | static CborError create_container(CborEncoder *encoder, CborEncoder *container, size_t length, uint8_t shiftedMajorType)
|
448 | 448 | {
|
449 | 449 | CborError err;
|
450 |
| - container->data.ptr = encoder->data.ptr; |
| 450 | + container->ptr = encoder->ptr; |
451 | 451 | container->end = encoder->end;
|
452 | 452 | ++encoder->added;
|
453 | 453 | container->added = 0;
|
@@ -527,9 +527,9 @@ CborError cbor_encoder_create_map(CborEncoder *encoder, CborEncoder *mapEncoder,
|
527 | 527 | CborError cbor_encoder_close_container(CborEncoder *encoder, const CborEncoder *containerEncoder)
|
528 | 528 | {
|
529 | 529 | if (encoder->end)
|
530 |
| - encoder->data.ptr = containerEncoder->data.ptr; |
| 530 | + encoder->ptr = containerEncoder->ptr; |
531 | 531 | else
|
532 |
| - encoder->data.bytes_needed = containerEncoder->data.bytes_needed; |
| 532 | + encoder->bytes_needed = containerEncoder->bytes_needed; |
533 | 533 | encoder->end = containerEncoder->end;
|
534 | 534 | if (containerEncoder->flags & CborIteratorFlag_UnknownLength)
|
535 | 535 | return append_byte_to_buffer(encoder, BreakByte);
|
|
0 commit comments