| 17 | namespace mllm::prefix_cache { |
| 18 | |
| 19 | ZenFSBlobMMAPFile::ptr_t ZenFSBlobMMAPFile::create(size_t size, ZenFSMMAPMode mode, const std::string& fpath, |
| 20 | std::error_code& ec) { |
| 21 | // Not throw std::bad_alloc but return nullptr |
| 22 | auto ptr = std::shared_ptr<ZenFSBlobMMAPFile>(new (std::nothrow) ZenFSBlobMMAPFile); |
| 23 | if (!ptr) { |
| 24 | ec = std::make_error_code(std::errc::not_enough_memory); |
| 25 | return nullptr; |
| 26 | } |
| 27 | bool ok = false; |
| 28 | if (mode == ZenFSMMAPMode::kAnonymous) { |
| 29 | ok = ptr->initAnonymous(size, ec); |
| 30 | } else { |
| 31 | ok = ptr->initFileBacked(size, mode, fpath, ec); |
| 32 | } |
| 33 | if (!ok) { ptr.reset(); } |
| 34 | return ptr; |
| 35 | } |
| 36 | |
| 37 | #if !defined(_WIN32) |
| 38 |
nothing calls this directly
no test coverage detected