aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Peach <mrpeach@users.sourceforge.net>2007-10-20 04:45:43 +0000
committerMartin Peach <mrpeach@users.sourceforge.net>2007-10-20 04:45:43 +0000
commit86377e19d315e04f5469a6090e7ea2f1ae5e8c4d (patch)
treedf438c8f6f5dc13f827cdfb951240d8f82bfe271
parentb60de94efa548d806a410596e37460a1d9417fe3 (diff)
Modified OSC_writeFloatArg for strict aliasing
svn path=/trunk/externals/mrpeach/; revision=8850
-rwxr-xr-xosc/packOSC.c12
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;