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

Method SetString

engine/ddf/src/ddf/ddf_message.cpp:316–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314 }
315
316 void Message::SetString(LoadContext* load_context, const FieldDescriptor* field, const char* buffer, int buffer_len)
317 {
318 assert((Type) field->m_Type == TYPE_STRING);
319
320 // Always alloc
321 char* str_buf = load_context->AllocString(buffer_len + 1);
322
323 if (!m_DryRun)
324 {
325 const char** string_field = (const char**) GetBuffer(field->m_Offset);
326 memcpy(str_buf, buffer, buffer_len);
327 str_buf[buffer_len] = '\0';
328
329 if (load_context->GetOptions() & OPTION_OFFSET_POINTERS)
330 {
331 *string_field = (char*)(uintptr_t) load_context->GetOffset(str_buf);
332 }
333 else
334 {
335 *string_field = str_buf;
336 }
337 }
338 }
339
340 void Message::AddString(LoadContext* load_context, const FieldDescriptor* field, const char* buffer, int buffer_len)
341 {

Callers 1

DoLoadDefaultFieldFunction · 0.80

Calls 5

AllocStringMethod · 0.80
GetOptionsMethod · 0.80
GetOffsetMethod · 0.80
assertFunction · 0.50
GetBufferFunction · 0.50

Tested by

no test coverage detected