MCPcopy Create free account
hub / github.com/defold/defold / SetBytes

Method SetBytes

engine/ddf/src/ddf/ddf_message.cpp:377–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 5

AllocBytesMethod · 0.80
GetOptionsMethod · 0.80
GetOffsetMethod · 0.80
assertFunction · 0.50
GetBufferFunction · 0.50

Tested by

no test coverage detected