aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/io
diff options
context:
space:
mode:
authorSteve Ellcey <sje@cup.hp.com>2004-12-14 16:34:08 +0000
committerSteve Ellcey <sje@gcc.gnu.org>2004-12-14 16:34:08 +0000
commit0865674700a1a95a3af07f6e2d197589033d5803 (patch)
tree3c213ca52a962036fb35fd4927257e6f48391718 /libgfortran/io
parent0cc1b87903e803bb92122b569a350ab1a2b0ff8a (diff)
downloadgcc-0865674700a1a95a3af07f6e2d197589033d5803.zip
gcc-0865674700a1a95a3af07f6e2d197589033d5803.tar.gz
gcc-0865674700a1a95a3af07f6e2d197589033d5803.tar.bz2
transfer.c (us_read): Use memcpy/memset instead of assignment to fill unaligned buffer.
* libgfortran/io/transfer.c (us_read): Use memcpy/memset instead of assignment to fill unaligned buffer. (us_write): Ditto. (next_record_w): Ditto. From-SVN: r92143
Diffstat (limited to 'libgfortran/io')
-rw-r--r--libgfortran/io/transfer.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index dc94154..c3daa21 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -827,11 +827,12 @@ transfer_complex (void *p, int kind)
static void
us_read (void)
{
- gfc_offset *p;
+ char *p;
int n;
+ gfc_offset i;
n = sizeof (gfc_offset);
- p = (gfc_offset *) salloc_r (current_unit->s, &n);
+ p = salloc_r (current_unit->s, &n);
if (p == NULL || n != sizeof (gfc_offset))
{
@@ -839,7 +840,8 @@ us_read (void)
return;
}
- current_unit->bytes_left = *p;
+ memcpy (&i, p, sizeof (gfc_offset));
+ current_unit->bytes_left = i;
}
@@ -849,11 +851,11 @@ us_read (void)
static void
us_write (void)
{
- gfc_offset *p;
+ char *p;
int length;
length = sizeof (gfc_offset);
- p = (gfc_offset *) salloc_w (current_unit->s, &length);
+ p = salloc_w (current_unit->s, &length);
if (p == NULL)
{
@@ -861,7 +863,7 @@ us_write (void)
return;
}
- *p = 0; /* Bogus value for now. */
+ memset (p, '\0', sizeof (gfc_offset)); /* Bogus value for now. */
if (sfree (current_unit->s) == FAILURE)
generate_error (ERROR_OS, NULL);
@@ -1285,7 +1287,7 @@ next_record_w (int done)
if (p == NULL)
goto io_error;
- *((gfc_offset *) p) = m;
+ memcpy (p, &m, sizeof (gfc_offset));
if (sfree (current_unit->s) == FAILURE)
goto io_error;
@@ -1296,7 +1298,7 @@ next_record_w (int done)
if (p == NULL)
generate_error (ERROR_OS, NULL);
- *((gfc_offset *) p) = m;
+ memcpy (p, &m, sizeof (gfc_offset));
if (sfree (current_unit->s) == FAILURE)
goto io_error;