From fca7d27283c3ee956c6273ba852ff399c48d6e4f Mon Sep 17 00:00:00 2001 From: Andrew McCallum Date: Thu, 31 Oct 1996 18:46:02 +0000 Subject: [PATCH] ([BinaryCStream -encodeValueOfCType:at:withName:name]): Use memcpy() instead of assignment to get the floats and doubles from the `at:' argument. ([BinaryCStream -decodeValueOfCType:at:withName:]): Likewise, for setting the values. (Reported by M. Decugis .) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1902 72102866-910b-0410-8b05-ffd578937521 --- Source/BinaryCStream.m | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/BinaryCStream.m b/Source/BinaryCStream.m index 4076ff7ae..4a0e40b2e 100644 --- a/Source/BinaryCStream.m +++ b/Source/BinaryCStream.m @@ -225,7 +225,8 @@ static int debug_binary_coder = 0; volatile double value; int exponent, mantissa; short exponent_encoded; - value = *(float*)d; + + memcpy (&value, d, sizeof (float)); /* Get the exponent */ value = frexp (value, &exponent); exponent_encoded = exponent; @@ -245,7 +246,8 @@ static int debug_binary_coder = 0; volatile double value; int exponent, mantissa1, mantissa2; short exponent_encoded; - value = *(double*)d; + + memcpy (&value, d, sizeof (double)); /* Get the exponent */ value = frexp (value, &exponent); exponent_encoded = exponent; @@ -383,7 +385,7 @@ static int debug_binary_coder = 0; { short exponent; int mantissa; - double value; + volatile double value; /* Decode the exponent and mantissa. */ READ_SIGNED_TYPE (&exponent, short, ntohs); READ_SIGNED_TYPE (&mantissa, int, ntohl); @@ -391,7 +393,7 @@ static int debug_binary_coder = 0; value = mantissa / FLOAT_FACTOR; value = ldexp (value, exponent); /* Put the double into the requested memory location as a float */ - *(float*)d = value; + memcpy (d, &value, sizeof (float)); break; } @@ -408,7 +410,7 @@ static int debug_binary_coder = 0; value = ((mantissa2 / FLOAT_FACTOR) + mantissa1) / FLOAT_FACTOR; value = ldexp (value, exponent); /* Put the double into the requested memory location. */ - *(double*)d = value; + memcpy (d, &value, sizeof (double)); break; }