From 1dce609c8ee560ec9f75961063f56cc58da84764 Mon Sep 17 00:00:00 2001 From: TazyFoundSoup Date: Thu, 21 May 2026 08:04:50 +1000 Subject: feat(common): add ff_write_be32 and le32 for inverse endianess functions --- include/tinyff/common.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/tinyff/common.h') diff --git a/include/tinyff/common.h b/include/tinyff/common.h index 891f9ee..1efe930 100644 --- a/include/tinyff/common.h +++ b/include/tinyff/common.h @@ -60,6 +60,21 @@ static inline uint32_t ff_le32(const uint8_t *b) { ((uint32_t)b[3] << 24); } +static inline void ff_write_be32(uint8_t *out, uint32_t v) +{ + out[0] = (v >> 24) & 0xFF; + out[1] = (v >> 16) & 0xFF; + out[2] = (v >> 8) & 0xFF; + out[3] = (v) & 0xFF; +} + +static inline void ff_write_le32(uint8_t *out, uint32_t v) +{ + out[0] = (v) & 0xFF; + out[1] = (v >> 8) & 0xFF; + out[2] = (v >> 16) & 0xFF; + out[3] = (v >> 24) & 0xFF; +} // Small stdlib helper functions static inline size_t ff_strlen(const char *str) -- cgit v1.2.3