| 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 | { |
no test coverage detected