changeset 24015:e2bf959a5a0d

util: add getbe{u,}int16 utility methods
author Augie Fackler <augie@google.com>
date Tue, 20 Jan 2015 14:09:57 -0500
parents 7d9367de2654
children fb93721cc229
files mercurial/util.h
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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;