| 10 | #include "sk_stdlib.h" |
| 11 | |
| 12 | IoBuffer::IoBuffer(size_t size, size_t alignment) { |
| 13 | assert(size > 0 && "IoBuffer size must be greater than 0"); |
| 14 | assert((alignment & (alignment - 1)) == 0 && |
| 15 | "IoBuffer alignment must be a power of 2"); |
| 16 | |
| 17 | auto* data = static_cast<uint8_t*>(aligned_alloc(alignment, size)); |
| 18 | assert(data != nullptr && "IoBuffer aligned_alloc failed"); |
| 19 | data_ = data; |
| 20 | size_ = size; |
| 21 | } |
| 22 | |
| 23 | IoBuffer::~IoBuffer() { |
| 24 | assert((data_ == nullptr) == (size_ == 0) && |
nothing calls this directly
no test coverage detected