MCPcopy Create free account
hub / github.com/GJDuck/e9patch / dupBytes

Function dupBytes

src/e9patch/e9json.cpp:171–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169 */
170static std::set<Bytes, BytesCmp> bytes_cache;
171static const uint8_t *dupBytes(const std::vector<uint8_t> &bytes)
172{
173 size_t len = bytes.size();
174 Bytes key = {bytes.data(), len};
175 auto i = bytes_cache.find(key);
176 if (i != bytes_cache.end())
177 return i->bytes;
178
179 uint8_t *new_bytes = new uint8_t[len];
180 memcpy(new_bytes, bytes.data(), len);
181 bytes_cache.insert({new_bytes, len});
182 return new_bytes;
183}
184static const uint8_t *dupBytes(const char *str)
185{
186 size_t len = strlen(str)+1;

Callers 2

makeBytesEntryFunction · 0.85
makeDataEntryFunction · 0.85

Calls 5

memcpyFunction · 0.85
strlenFunction · 0.50
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected