[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r17261: {tor} define get_uint8 and set_uint8 macros to make code cleaner. (tor/trunk/src/common)



Author: nickm
Date: 2008-11-12 09:39:25 -0500 (Wed, 12 Nov 2008)
New Revision: 17261

Modified:
   tor/trunk/src/common/compat.h
Log:
define get_uint8 and set_uint8 macros to make code cleaner.

Modified: tor/trunk/src/common/compat.h
===================================================================
--- tor/trunk/src/common/compat.h	2008-11-12 14:26:38 UTC (rev 17260)
+++ tor/trunk/src/common/compat.h	2008-11-12 14:39:25 UTC (rev 17261)
@@ -443,6 +443,15 @@
 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