summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-11-12 14:39:25 +0000
committerNick Mathewson <nickm@torproject.org>2008-11-12 14:39:25 +0000
commita790a13705e9d838a4092435ed981179054c6beb (patch)
tree3fc28ecd688d9c81e84ed2f9e929aace497d2c31 /src/common
parent8f1952bf11561f98d2eea431ca58a17d70d951b2 (diff)
downloadtor-a790a13705e9d838a4092435ed981179054c6beb.tar.gz
tor-a790a13705e9d838a4092435ed981179054c6beb.zip
define get_uint8 and set_uint8 macros to make code cleaner.
svn:r17261
Diffstat (limited to 'src/common')
-rw-r--r--src/common/compat.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/compat.h b/src/common/compat.h
index 748b4e6538..292ff757be 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -443,6 +443,15 @@ uint32_t get_uint32(const char *cp) ATTR_PURE ATTR_NONNULL((1));
void set_uint16(char *cp, uint16_t v) ATTR_NONNULL((1));
void set_uint32(char *cp, uint32_t v) ATTR_NONNULL((1));
+/* These uint8 variants are defined to make the code more uniform. */
+#define get_uint8(cp) (*(const uint8_t*)(cp))
+static void set_uint8(char *cp, uint8_t v);
+static INLINE void
+set_uint8(char *cp, uint8_t v)
+{
+ *(uint8_t*)cp = v;
+}
+
#if !defined(HAVE_RLIM_T)
typedef unsigned long rlim_t;
#endif