MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / copy_flattened_data

Method copy_flattened_data

lib/asmjit/asmjit/core/codeholder.cpp:1341–1372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1339}
1340
1341Error CodeHolder::copy_flattened_data(void* dst, size_t dst_size, CopySectionFlags copy_flags) noexcept {
1342 size_t end = 0;
1343 for (Section* section : _sections_by_order) {
1344 if (section->offset() > dst_size) {
1345 return make_error(Error::kInvalidArgument);
1346 }
1347
1348 size_t buffer_size = section->buffer_size();
1349 size_t offset = size_t(section->offset());
1350
1351 if (ASMJIT_UNLIKELY(dst_size - offset < buffer_size)) {
1352 return make_error(Error::kInvalidArgument);
1353 }
1354
1355 uint8_t* dst_target = static_cast<uint8_t*>(dst) + offset;
1356 size_t padding_size = 0;
1357 memcpy(dst_target, section->data(), buffer_size);
1358
1359 if (Support::test(copy_flags, CopySectionFlags::kPadSectionBuffer) && buffer_size < section->virtual_size()) {
1360 padding_size = Support::min<size_t>(dst_size - offset, size_t(section->virtual_size())) - buffer_size;
1361 memset(dst_target + buffer_size, 0, padding_size);
1362 }
1363
1364 end = Support::max(end, offset + buffer_size + padding_size);
1365 }
1366
1367 if (end < dst_size && Support::test(copy_flags, CopySectionFlags::kPadTargetBuffer)) {
1368 memset(static_cast<uint8_t*>(dst) + end, 0, dst_size - end);
1369 }
1370
1371 return Error::kOk;
1372}
1373
1374// CodeHolder - Tests
1375// ==================

Callers 3

write_empty_function_atFunction · 0.80
copyBufferMethod · 0.80
copyBufferMethod · 0.80

Calls 8

make_errorFunction · 0.85
memcpyFunction · 0.85
testFunction · 0.85
maxFunction · 0.85
buffer_sizeMethod · 0.80
virtual_sizeMethod · 0.80
offsetMethod · 0.45
dataMethod · 0.45

Tested by 1

write_empty_function_atFunction · 0.64