From 5ea6ea476ef334ca565274d7a2f255db88c4788a Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 8 Jun 2012 02:10:02 +0900 Subject: [PATCH] Rewritten to_uint32 using shift --- examples/htparse/htparse.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/examples/htparse/htparse.c b/examples/htparse/htparse.c index 1fcbd51..64a3840 100644 --- a/examples/htparse/htparse.c +++ b/examples/htparse/htparse.c @@ -185,12 +185,7 @@ static const char * method_strmap[] = { }; static inline uint32_t to_uint32(char *m) { - union { - uint32_t i; - char data[4]; - } u; - memcpy(u.data, m, 4); - return u.i; + return (m[3] << 24) | (m[2] << 16) | (m[1] << 8) | m[0]; } #define _MIN_READ(a, b) ((a) < (b) ? (a) : (b))