summaryrefslogtreecommitdiff
path: root/libgfortran/generated/sum_r4.c
diff options
context:
space:
mode:
authorjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2014-06-17 03:50:34 +0000
committerjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2014-06-17 03:50:34 +0000
commitaf1e9051537d4e462a54367ca2f6544a2838e0f1 (patch)
tree4828a12bfc69bd396a89760cbc33905604e9f9ed /libgfortran/generated/sum_r4.c
parentd244ad0cb8516514ff6a562ed3cf88cef99a419b (diff)
downloadgcc-af1e9051537d4e462a54367ca2f6544a2838e0f1.tar.gz
Introduce xmallocarray, an overflow checking variant of xmalloc.
2014-06-17 Janne Blomqvist <jb@gcc.gnu.org> * libgfortran.h (xmallocarray): New prototype. * runtime/memory.c (xmallocarray): New function. (xcalloc): Check for nonzero separately instead of multiplying. * generated/*.c: Regenerated. * intrinsics/cshift0.c (cshift0): Call xmallocarray instead of xmalloc. * intrinsics/eoshift0.c (eoshift0): Likewise. * intrinsics/eoshift2.c (eoshift2): Likewise. * intrinsics/pack_generic.c (pack_internal): Likewise. (pack_s_internal): Likewise. * intrinsics/reshape_generic.c (reshape_internal): Likewise. * intrinsics/spread_generic.c (spread_internal): Likewise. (spread_internal_scalar): Likewise. * intrinsics/string_intrinsics_inc.c (string_trim): Likewise. (string_minmax): Likewise. * intrinsics/transpose_generic.c (transpose_internal): Likewise. * intrinsics/unpack_generic.c (unpack_internal): Likewise. * io/list_read.c (nml_touch_nodes): Don't cast xmalloc return value. * io/transfer.c (st_set_nml_var): Call xmallocarray instead of xmalloc. * io/unit.c (get_internal_unit): Likewise. (filename_from_unit): Don't cast xmalloc return value. * io/write.c (nml_write_obj): Likewise, formatting. * m4/bessel.m4 (bessel_jn_r'rtype_kind`): Call xmallocarray instead of xmalloc. (besse_yn_r'rtype_kind`): Likewise. * m4/cshift1.m4 (cshift1): Likewise. * m4/eoshift1.m4 (eoshift1): Likewise. * m4/eoshift3.m4 (eoshift3): Likewise. * m4/iforeach.m4: Likewise. * m4/ifunction.m4: Likewise. * m4/ifunction_logical.m4 (name`'rtype_qual`_'atype_code): Likewise. * m4/in_pack.m4 (internal_pack_'rtype_ccode`): Likewise. * m4/matmul.m4 (matmul_'rtype_code`): Likewise. * m4/matmull.m4 (matmul_'rtype_code`): Likewise. * m4/pack.m4 (pack_'rtype_code`): Likewise. * m4/reshape.m4 (reshape_'rtype_ccode`): Likewise. * m4/shape.m4 (shape_'rtype_kind`): Likewise. * m4/spread.m4 (spread_'rtype_code`): Likewise. (spread_scalar_'rtype_code`): Likewise. * m4/transpose.m4 (transpose_'rtype_code`): Likewise. * m4/unpack.m4 (unpack0_'rtype_code`): Likewise. (unpack1_'rtype_code`): Likewise. * runtime/convert_char.c (convert_char1_to_char4): Likewise. (convert_char4_to_char1): Simplify. * runtime/environ.c (init_unformatted): Call xmallocarray instead of xmalloc. * runtime/in_pack_generic.c (internal_pack): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211721 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/generated/sum_r4.c')
-rw-r--r--libgfortran/generated/sum_r4.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/libgfortran/generated/sum_r4.c b/libgfortran/generated/sum_r4.c
index 2fea0b7e259..a3a4b59cee6 100644
--- a/libgfortran/generated/sum_r4.c
+++ b/libgfortran/generated/sum_r4.c
@@ -97,10 +97,9 @@ sum_r4 (gfc_array_r4 * const restrict retarray,
retarray->offset = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
- alloc_size = sizeof (GFC_REAL_4) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
- * extent[rank-1];
+ alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
- retarray->base_addr = xmalloc (alloc_size);
+ retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_REAL_4));
if (alloc_size == 0)
{
/* Make sure we have a zero-sized array. */
@@ -272,8 +271,7 @@ msum_r4 (gfc_array_r4 * const restrict retarray,
}
- alloc_size = sizeof (GFC_REAL_4) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
- * extent[rank-1];
+ alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
retarray->offset = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
@@ -285,7 +283,7 @@ msum_r4 (gfc_array_r4 * const restrict retarray,
return;
}
else
- retarray->base_addr = xmalloc (alloc_size);
+ retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_REAL_4));
}
else
@@ -430,8 +428,7 @@ ssum_r4 (gfc_array_r4 * const restrict retarray,
retarray->offset = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
- alloc_size = sizeof (GFC_REAL_4) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
- * extent[rank-1];
+ alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
if (alloc_size == 0)
{
@@ -440,7 +437,7 @@ ssum_r4 (gfc_array_r4 * const restrict retarray,
return;
}
else
- retarray->base_addr = xmalloc (alloc_size);
+ retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_REAL_4));
}
else
{