summaryrefslogtreecommitdiff
path: root/libgfortran/m4
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran/m4')
-rw-r--r--libgfortran/m4/eoshift1.m47
-rw-r--r--libgfortran/m4/eoshift3.m46
-rw-r--r--libgfortran/m4/pack.m412
-rw-r--r--libgfortran/m4/spread.m412
4 files changed, 14 insertions, 23 deletions
diff --git a/libgfortran/m4/eoshift1.m4 b/libgfortran/m4/eoshift1.m4
index be9b1008a60..339e1d89965 100644
--- a/libgfortran/m4/eoshift1.m4
+++ b/libgfortran/m4/eoshift1.m4
@@ -89,7 +89,6 @@ eoshift1 (gfc_array_char * const restrict ret,
{
int i;
- ret->data = internal_malloc_size (size * arraysize);
ret->offset = 0;
ret->dtype = array->dtype;
for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
@@ -107,10 +106,8 @@ eoshift1 (gfc_array_char * const restrict ret,
GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
}
- if (arraysize > 0)
- ret->data = internal_malloc_size (size * arraysize);
- else
- ret->data = internal_malloc_size (1);
+ /* internal_malloc_size allocates a single byte for zero size. */
+ ret->data = internal_malloc_size (size * arraysize);
}
else if (unlikely (compile_options.bounds_check))
diff --git a/libgfortran/m4/eoshift3.m4 b/libgfortran/m4/eoshift3.m4
index 6fa3bd2f7dc..1c19575ffb8 100644
--- a/libgfortran/m4/eoshift3.m4
+++ b/libgfortran/m4/eoshift3.m4
@@ -108,10 +108,8 @@ eoshift3 (gfc_array_char * const restrict ret,
GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
}
- if (arraysize > 0)
- ret->data = internal_malloc_size (size * arraysize);
- else
- ret->data = internal_malloc_size (1);
+ /* internal_malloc_size allocates a single byte for zero size. */
+ ret->data = internal_malloc_size (size * arraysize);
}
else if (unlikely (compile_options.bounds_check))
diff --git a/libgfortran/m4/pack.m4 b/libgfortran/m4/pack.m4
index c5fd2fd817d..e1882d077c2 100644
--- a/libgfortran/m4/pack.m4
+++ b/libgfortran/m4/pack.m4
@@ -167,14 +167,12 @@ pack_'rtype_code` ('rtype` *ret, const 'rtype` *array,
GFC_DIMENSION_SET(ret->dim[0], 0, total-1, 1);
ret->offset = 0;
+
+ /* internal_malloc_size allocates a single byte for zero size. */
+ ret->data = internal_malloc_size (sizeof ('rtype_name`) * total);
+
if (total == 0)
- {
- /* In this case, nothing remains to be done. */
- ret->data = internal_malloc_size (1);
- return;
- }
- else
- ret->data = internal_malloc_size (sizeof ('rtype_name`) * total);
+ return;
}
else
{
diff --git a/libgfortran/m4/spread.m4 b/libgfortran/m4/spread.m4
index 5e73d97423a..89a2e65297c 100644
--- a/libgfortran/m4/spread.m4
+++ b/libgfortran/m4/spread.m4
@@ -101,13 +101,11 @@ spread_'rtype_code` ('rtype` *ret, const 'rtype` *source,
GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
}
ret->offset = 0;
- if (rs > 0)
- ret->data = internal_malloc_size (rs * sizeof('rtype_name`));
- else
- {
- ret->data = internal_malloc_size (1);
- return;
- }
+
+ /* internal_malloc_size allocates a single byte for zero size. */
+ ret->data = internal_malloc_size (rs * sizeof('rtype_name`));
+ if (rs <= 0)
+ return;
}
else
{