Showing the changes to src/vm/module_reader.cpp (1 of 2 files). Show all
Unified · Split
| @@ -141,23 +141,6 @@ namespace · 140 unmodified lines | ||
| 141 | 141 | return r; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | − bool read_next_string(util::buffered_reader_t &reader, std::vector<uint8_t> &char_buffer) | |
| 145 | − { | |
| 146 | − assert(char_buffer.size() == 0); | |
| 147 | − char_buffer.reserve(1024); | |
| 148 | − | |
| 149 | − auto success = bool{}; | |
| 150 | − auto value = uint8_t{}; | |
| 151 | − std::tie(success, value) = reader.get_next_byte(); | |
| 152 | − while (success && value != 0) | |
| 153 | − { | |
| 154 | − char_buffer.push_back(value); | |
| 155 | − std::tie(success, value) = reader.get_next_byte(); | |
| 156 | − } | |
| 157 | − | |
| 158 | − return success; | |
| 159 | − } | |
| 160 | − | |
| 161 | 144 | byte_t *read_8byte_segments(util::buffered_reader_t &reader, datum_type_t type, uint32_t segment_count, byte_t *dest) |
| 162 | 145 | { |
| 163 | 146 | assert(type == datum_type_t::value_real64 || type == datum_type_t::value_bit64); |
| @@ -519,7 +502,7 @@ namespace · 355 unmodified lines | ||
| 519 | 502 | void read_module_name(util::buffered_reader_t &reader, vm_module_t &modobj) |
| 520 | 503 | { |
| 521 | 504 | auto string_buffer = std::vector<uint8_t>{}; |
| 522 | − if (!read_next_string(reader, string_buffer)) | |
| 505 | + if (!reader.get_bytes_until(0, string_buffer)) | |
| 523 | 506 | throw module_reader_exception{ "Failed to read module name" }; |
| 524 | 507 | |
| 525 | 508 | modobj.module_name = std::make_unique<vm_string_t>(string_buffer.size(), string_buffer.data()); |
| @@ -550,7 +533,7 @@ namespace · 24 unmodified lines | ||
| 550 | 533 | if (!success) throw module_reader_exception{ "Failed to read linkage signature" }; |
| 551 | 534 | |
| 552 | 535 | auto string_buffer = std::vector<uint8_t>{}; |
| 553 | − if (!read_next_string(reader, string_buffer)) | |
| 536 | + if (!reader.get_bytes_until(0, string_buffer)) | |
| 554 | 537 | throw module_reader_exception{ "Failed to read linkage name" }; |
| 555 | 538 | |
| 556 | 539 | item.name = std::make_unique<vm_string_t>(string_buffer.size(), string_buffer.data()); |
| @@ -594,7 +577,7 @@ namespace · 37 unmodified lines | ||
| 594 | 577 | if (!success) throw module_reader_exception{ "Failed to read import function signature" }; |
| 595 | 578 | |
| 596 | 579 | auto string_buffer = std::vector<uint8_t>{}; |
| 597 | − if (!read_next_string(reader, string_buffer)) | |
| 580 | + if (!reader.get_bytes_until(0, string_buffer)) | |
| 598 | 581 | throw module_reader_exception{ "Failed to read import function name" }; |
| 599 | 582 | |
| 600 | 583 | func.name = std::make_unique<vm_string_t>(string_buffer.size(), string_buffer.data()); |
| @@ -666,7 +649,7 @@ namespace · 65 unmodified lines | ||
| 666 | 649 | exception_t except{}; |
| 667 | 650 | |
| 668 | 651 | auto string_buffer = std::vector<uint8_t>{}; |
| 669 | − if (!read_next_string(reader, string_buffer)) | |
| 652 | + if (!reader.get_bytes_until(0, string_buffer)) | |
| 670 | 653 | throw module_reader_exception{ "Failed to read exception name" }; |
| 671 | 654 | |
| 672 | 655 | except.name = std::make_unique<vm_string_t>(string_buffer.size(), string_buffer.data()); |