| 1412 | if (numPages > 0) { |
| 1413 | pool.allocateNonContiguous(numPages, allocation_); |
| 1414 | } |
| 1415 | } |
| 1416 | |
| 1417 | void RowPartitions::appendPartitions(folly::Range<const uint8_t*> partitions) { |
| 1418 | int32_t toAdd = partitions.size(); |
| 1419 | int index = 0; |
| 1420 | BOLT_CHECK_LE(size_ + toAdd, capacity_); |
| 1421 | while (toAdd) { |
| 1422 | int32_t run; |
| 1423 | int32_t offset; |
| 1424 | allocation_.findRun(size_, &run, &offset); |
| 1425 | auto runSize = allocation_.runAt(run).numBytes(); |
| 1426 | auto copySize = std::min<int32_t>(toAdd, runSize - offset); |
| 1427 | memcpy( |
| 1428 | allocation_.runAt(run).data<uint8_t>() + offset, |
| 1429 | &partitions[index], |
| 1430 | copySize); |
| 1431 | size_ += copySize; |
| 1432 | index += copySize; |
| 1433 | toAdd -= copySize; |
| 1434 | // Zero out to the next multiple of SIMD width for asan/valgring. |
| 1435 | if (!toAdd) { |
| 1436 | bits::padToAlignment( |
| 1437 | allocation_.runAt(run).data<uint8_t>(), |
| 1438 | runSize, |
| 1439 | offset + copySize, |
| 1440 | xsimd::batch<uint8_t>::size); |
| 1441 | } |
| 1442 | } |
| 1443 | } |