Extract bit operations to buffer_util.h

Move util functions to a reusable separate header.
This commit is contained in:
Romain Vimont
2018-11-11 00:48:25 +01:00
parent b1d2c2c640
commit cb3cf801c8
2 changed files with 29 additions and 22 deletions

18
app/src/buffer_util.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef BUFFER_UTIL_H
#define BUFFER_UTIL_H
#include <SDL2/SDL_stdinc.h>
static inline void buffer_write16be(Uint8 *buf, Uint16 value) {
buf[0] = value >> 8;
buf[1] = value;
}
static inline void buffer_write32be(Uint8 *buf, Uint32 value) {
buf[0] = value >> 24;
buf[1] = value >> 16;
buf[2] = value >> 8;
buf[3] = value;
}
#endif