Move buffer reader functions to buffer_util.h

This commit is contained in:
Romain Vimont
2018-11-11 00:58:29 +01:00
parent b98eb7d0fa
commit ebe998cf78
2 changed files with 13 additions and 15 deletions

View File

@@ -15,4 +15,14 @@ static inline void buffer_write32be(Uint8 *buf, Uint32 value) {
buf[3] = value;
}
static inline Uint32 buffer_read32be(Uint8 *buf) {
return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
}
static inline Uint64 buffer_read64be(Uint8 *buf) {
Uint32 msb = buffer_read32be(buf);
Uint32 lsb = buffer_read32be(&buf[4]);
return ((Uint64) msb << 32) | lsb;
}
#endif