| 338 | } |
| 339 | |
| 340 | static Cache::UniquePendingHandle CreateEntry( |
| 341 | Cache* cache, const Slice& key, const string& path) { |
| 342 | Cache::UniquePendingHandle pending = |
| 343 | cache->Allocate(key, sizeof(TupleCacheEntry) + path.size() + 1); |
| 344 | if (!pending) { |
| 345 | return pending; |
| 346 | } |
| 347 | |
| 348 | // buf is used to store a TupleCacheEntry, followed by the path. |
| 349 | uint8_t* buf = cache->MutableValue(&pending); |
| 350 | new (buf) TupleCacheEntry{}; |
| 351 | char* path_s = reinterpret_cast<char*>(buf + sizeof(TupleCacheEntry)); |
| 352 | memcpy(path_s, path.data(), path.size()); |
| 353 | // Null terminate because UniquePendingHandle doesn't provide access to size. |
| 354 | path_s[path.size()] = '\0'; |
| 355 | |
| 356 | return pending; |
| 357 | } |
| 358 | |
| 359 | // If the entry exists, the Handle pins it so it doesn't go away, but the entry may be in |
| 360 | // any state (IN PROGRESS, TOMBSTONE, COMPLETE_UNSYNCED, COMPLETE). If the entry doesn't |
no test coverage detected