MCPcopy Create free account
hub / github.com/MhmRdd/NoHello / xread

Function xread

module/src/main/cpp/utils.cpp:367–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

365
366template <typename T>
367std::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
382template<>
383std::unique_ptr<std::string> xread<std::string>(int fd) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected