MCPcopy Create free account
hub / github.com/Tencent/tgfx / MakeWithCopy

Method MakeWithCopy

src/core/Data.cpp:38–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38std::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
51std::shared_ptr<Data> Data::MakeWithoutCopy(const void* data, size_t length) {
52 if (length == 0) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected