util: add getbe{u,}int16 utility methods
authorAugie Fackler <augie@google.com>
Tue, 20 Jan 2015 14:09:57 -0500
changeset 24015 e2bf959a5a0d
parent 24014 7d9367de2654
child 24016 fb93721cc229
util: add getbe{u,}int16 utility methods
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;