| 36 | } |
| 37 | |
| 38 | std::shared_ptr<Data> Data::MakeWithCopy(const void* bytes, size_t length) { |
| 39 | if (length == 0) { |
| 40 | return MakeEmpty(); |
| 41 | } |
| 42 | auto data = new (std::nothrow) uint8_t[length]; |
| 43 | if (data == nullptr) { |
| 44 | return nullptr; |
| 45 | } |
| 46 | memcpy(data, bytes, length); |
| 47 | auto byteData = new Data(data, length, Data::DeleteProc, nullptr); |
| 48 | return std::shared_ptr<Data>(byteData); |
| 49 | } |
| 50 | |
| 51 | std::shared_ptr<Data> Data::MakeWithoutCopy(const void* data, size_t length) { |
| 52 | if (length == 0) { |
nothing calls this directly
no outgoing calls
no test coverage detected