| 169 | */ |
| 170 | static std::set<Bytes, BytesCmp> bytes_cache; |
| 171 | static 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 | } |
| 184 | static const uint8_t *dupBytes(const char *str) |
| 185 | { |
| 186 | size_t len = strlen(str)+1; |
no test coverage detected