| 365 | |
| 366 | template <typename T> |
| 367 | std::unique_ptr<T> xread(int fd) { |
| 368 | uint64_t size = 0; |
| 369 | if (read(fd, &size, sizeof(size)) != sizeof(size)) { |
| 370 | return nullptr; |
| 371 | } |
| 372 | if (size != sizeof(T)) { |
| 373 | return nullptr; |
| 374 | } |
| 375 | auto data = std::make_unique<T>(); |
| 376 | if (read(fd, data.get(), size) != static_cast<ssize_t>(size)) { |
| 377 | return nullptr; |
| 378 | } |
| 379 | return data; |
| 380 | } |
| 381 | |
| 382 | template<> |
| 383 | std::unique_ptr<std::string> xread<std::string>(int fd) { |
nothing calls this directly
no outgoing calls
no test coverage detected