# HG changeset patch # User Augie Fackler # Date 1421780997 18000 # Node ID e2bf959a5a0d5950df82de2698b25aa76243d790 # Parent 7d9367de2654b9bfec0a099273474a65ec88caea util: add getbe{u,}int16 utility methods diff -r 7d9367de2654 -r e2bf959a5a0d mercurial/util.h --- a/mercurial/util.h Tue Jan 20 09:38:22 2015 -0500 +++ b/mercurial/util.h Tue Jan 20 14:09:57 2015 -0500 @@ -172,6 +172,22 @@ (d[3])); } +static inline int16_t getbeint16(const char *c) +{ + const unsigned char *d = (const unsigned char *)c; + + return ((d[0] << 8) | + (d[1])); +} + +static inline uint16_t getbeuint16(const char *c) +{ + const unsigned char *d = (const unsigned char *)c; + + return ((d[0] << 8) | + (d[1])); +} + static inline void putbe32(uint32_t x, char *c) { c[0] = (x >> 24) & 0xff;