MCPcopy Create free account
hub / github.com/WebAssembly/wabt / ReadT

Method ReadT

src/binary-reader.cc:292–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290
291template <typename T>
292Result BinaryReader::ReadT(T* out_value,
293 const char* type_name,
294 const char* desc) {
295 if (state_.offset + sizeof(T) > read_end_) {
296 PrintError("unable to read %s: %s", type_name, desc);
297 return Result::Error;
298 }
299#if WABT_BIG_ENDIAN
300 uint8_t tmp[sizeof(T)];
301 memcpy(tmp, state_.data + state_.offset, sizeof(tmp));
302 SwapBytesSized(tmp, sizeof(tmp));
303 memcpy(out_value, tmp, sizeof(T));
304#else
305 memcpy(out_value, state_.data + state_.offset, sizeof(T));
306#endif
307 state_.offset += sizeof(T);
308 return Result::Ok;
309}
310
311Result BinaryReader::ReadU8(uint8_t* out_value, const char* desc) {
312 return ReadT(out_value, "uint8_t", desc);

Callers

nothing calls this directly

Calls 1

SwapBytesSizedFunction · 0.85

Tested by

no test coverage detected