| 375 | } |
| 376 | |
| 377 | void Message::SetBytes(LoadContext* load_context, const FieldDescriptor* field, const char* buffer, int buffer_len) |
| 378 | { |
| 379 | assert((Type) field->m_Type == TYPE_BYTES); |
| 380 | |
| 381 | // Always alloc |
| 382 | char* bytes_buf = load_context->AllocBytes(buffer_len); |
| 383 | |
| 384 | if (!m_DryRun) |
| 385 | { |
| 386 | memcpy(bytes_buf, buffer, buffer_len); |
| 387 | |
| 388 | RepeatedField* repeated_field = (RepeatedField*) GetBuffer(field->m_Offset); |
| 389 | assert(repeated_field->m_ArrayCount == 0); |
| 390 | |
| 391 | if (load_context->GetOptions() & OPTION_OFFSET_POINTERS) |
| 392 | { |
| 393 | repeated_field->m_Array = (uintptr_t) load_context->GetOffset(bytes_buf); |
| 394 | } |
| 395 | else |
| 396 | { |
| 397 | repeated_field->m_Array = (uintptr_t) bytes_buf; |
| 398 | } |
| 399 | repeated_field->m_ArrayCount = buffer_len; |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | void Message::AllocateRepeatedBuffer(LoadContext* load_context, const FieldDescriptor* field, int element_count) |
| 404 | { |
nothing calls this directly
no test coverage detected