diff options
author | Martin Peach <mrpeach@users.sourceforge.net> | 2007-10-20 04:45:43 +0000 |
---|---|---|
committer | Martin Peach <mrpeach@users.sourceforge.net> | 2007-10-20 04:45:43 +0000 |
commit | 86377e19d315e04f5469a6090e7ea2f1ae5e8c4d (patch) | |
tree | df438c8f6f5dc13f827cdfb951240d8f82bfe271 | |
parent | b60de94efa548d806a410596e37460a1d9417fe3 (diff) |
Modified OSC_writeFloatArg for strict aliasing
svn path=/trunk/externals/mrpeach/; revision=8850
-rwxr-xr-x | osc/packOSC.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/osc/packOSC.c b/osc/packOSC.c index 0849769..3b66782 100755 --- a/osc/packOSC.c +++ b/osc/packOSC.c @@ -1119,15 +1119,21 @@ static int CheckTypeTag(OSCbuf *buf, char expectedType) static int OSC_writeFloatArg(OSCbuf *buf, float arg) { - int4byte *intp; + union intfloat32 + { + int i; + float f; + }; + union intfloat32 if32; if(OSC_CheckOverflow(buf, 4))return 1; if (CheckTypeTag(buf, 'f')) return 9; /* Pretend arg is a long int so we can use htonl() */ - intp = ((int4byte *) &arg); - *((int4byte *) buf->bufptr) = htonl(*intp); + if32.f = arg; + + *((int4byte *) buf->bufptr) = htonl(if32.i); buf->bufptr += 4; |