MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / read4

Method read4

Source/ThirdParty/streamreader.hh:80–98  ·  view source on GitHub ↗

Read 4 bytes (uint32_t) with endian swap if needed

Source from the content-addressed store, hash-verified

78
79 // Read 4 bytes (uint32_t) with endian swap if needed
80 bool read4(uint32_t* dst) {
81 if (!dst) {
82 return false;
83 }
84 uint8_t buf[4];
85 if (!read(4, buf)) {
86 return false;
87 }
88
89 if (needs_swap_) {
90 *dst = static_cast<uint32_t>(buf[3]) << 24 |
91 static_cast<uint32_t>(buf[2]) << 16 |
92 static_cast<uint32_t>(buf[1]) << 8 |
93 static_cast<uint32_t>(buf[0]);
94 } else {
95 std::memcpy(dst, buf, 4);
96 }
97 return true;
98 }
99
100 // Read 8 bytes (uint64_t) with endian swap if needed
101 bool read8(uint64_t* dst) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected