Skip to content

Commit

Permalink
take care of strict aliasing
Browse files Browse the repository at this point in the history
  • Loading branch information
skywind3000 committed Apr 24, 2020
1 parent 53e568b commit 38e0c93
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ikcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static inline char *ikcp_encode16u(char *p, unsigned short w)
*(unsigned char*)(p + 0) = (w & 255);
*(unsigned char*)(p + 1) = (w >> 8);
#else
*(unsigned short*)(p) = w;
memcpy(p, &w, 2);
#endif
p += 2;
return p;
Expand All @@ -84,7 +84,7 @@ static inline const char *ikcp_decode16u(const char *p, unsigned short *w)
*w = *(const unsigned char*)(p + 1);
*w = *(const unsigned char*)(p + 0) + (*w << 8);
#else
*w = *(const unsigned short*)p;
memcpy(w, p, 2);
#endif
p += 2;
return p;
Expand All @@ -99,7 +99,7 @@ static inline char *ikcp_encode32u(char *p, IUINT32 l)
*(unsigned char*)(p + 2) = (unsigned char)((l >> 16) & 0xff);
*(unsigned char*)(p + 3) = (unsigned char)((l >> 24) & 0xff);
#else
*(IUINT32*)p = l;
memcpy(p, &l, 4);
#endif
p += 4;
return p;
Expand All @@ -114,7 +114,7 @@ static inline const char *ikcp_decode32u(const char *p, IUINT32 *l)
*l = *(const unsigned char*)(p + 1) + (*l << 8);
*l = *(const unsigned char*)(p + 0) + (*l << 8);
#else
*l = *(const IUINT32*)p;
memcpy(l, p, 4);
#endif
p += 4;
return p;
Expand Down

0 comments on commit 38e0c93

Please sign in to comment.