diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2011-11-17 19:58:31 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2011-11-17 19:58:31 +0000 |
commit | e1f0d7064d41ad7e1ee41375253f93c43db4dc32 (patch) | |
tree | 64d5e1e65a3124a7d8b40da818a8b3dfe50ac93e /src | |
parent | 8b1145a2bcd61ea404b1f611429ec619b5f426ed (diff) |
replaced type-punning with int/float union
svn path=/trunk/externals/OSCx/; revision=15789
Diffstat (limited to 'src')
-rw-r--r-- | src/dumpOSC.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/dumpOSC.c b/src/dumpOSC.c index cf74299..28405c3 100644 --- a/src/dumpOSC.c +++ b/src/dumpOSC.c @@ -538,7 +538,7 @@ void PrintClientAddr(ClientAddr CA) { printf(" clilen %d, sockfd %d\n", CA->clilen, CA->sockfd);
printf(" sin_family %d, sin_port %d\n", CA->cl_addr.sin_family,
CA->cl_addr.sin_port);
- printf(" address: (%x) %s\n", addr, inet_ntoa(CA->cl_addr.sin_addr));
+ printf(" address: (%lx) %s\n", addr, inet_ntoa(CA->cl_addr.sin_addr));
printf(" sin_zero = \"%c%c%c%c%c%c%c%c\"\n",
CA->cl_addr.sin_zero[0],
@@ -902,6 +902,11 @@ static void dumpOSC_PrintHeuristicallyTypeGuessedArgs(t_dumpOSC *x, void *v, int t_atom* mya = x->x_outat;
//int myi;
+ union
+ {
+ float f;
+ int32_t i;
+ }u;
/* Go through the arguments 32 bits at a time */
ints = v;
@@ -909,9 +914,9 @@ static void dumpOSC_PrintHeuristicallyTypeGuessedArgs(t_dumpOSC *x, void *v, int for (i = 0; i<n/4; ) {
string = &chars[i*4];
- thisi = ntohl(ints[i]);
+ u.i = thisi = ntohl(ints[i]);
/* Reinterpret the (potentially byte-reversed) thisi as a float */
- thisf = *(((t_float *) (&thisi)));
+ thisf = (t_float) u.f;
if (thisi >= -1000 && thisi <= 1000000) {
#ifdef DEBUG
|