* runtime/memory.c (internal_malloc_size): If size is zero,
allocate a single byte.
* m4/pack.m4 (pack_'rtype_code`): Don't check for zero size
for the argument of internal_malloc_size.
* m4/spread.m4 (spread_'rtype_code`): Likewise.
* m4/eoshift1.m4 (eoshift1): Don't allocate twice. Don't check
for zero size for the argument of internal_malloc_size.
* m4/eoshift3.m4: Don't check for zero size for the argument of
internal_malloc_size.
* intrinsics/pack_generic.c (pack_internal): Likewise.
(pack_s_internal): Likewise.
* intrinsics/cshift0.c (cshift0): Likewise.
* intrinsics/spread_generic.c (spread_internal): Likewise.
* intrinsics/eoshift0.c (eoshift0): Likewise.
* intrinsics/eoshift2.c (eoshift2): Likewise.
* generated/eoshift1_16.c: Regenerated.
* generated/eoshift1_4.c: Regenerated.
* generated/eoshift1_8.c: Regenerated.
* generated/eoshift3_16.c: Regenerated.
* generated/eoshift3_4.c: Regenerated.
* generated/eoshift3_8.c: Regenerated.
* generated/pack_c10.c: Regenerated.
* generated/pack_c16.c: Regenerated.
* generated/pack_c4.c: Regenerated.
* generated/pack_c8.c: Regenerated.
* generated/pack_i16.c: Regenerated.
* generated/pack_i1.c: Regenerated.
* generated/pack_i2.c: Regenerated.
* generated/pack_i4.c: Regenerated.
* generated/pack_i8.c: Regenerated.
* generated/pack_r10.c: Regenerated.
* generated/pack_r16.c: Regenerated.
* generated/pack_r4.c: Regenerated.
* generated/pack_r8.c: Regenerated.
* generated/spread_c10.c: Regenerated.
* generated/spread_c16.c: Regenerated.
* generated/spread_c4.c: Regenerated.
* generated/spread_c8.c: Regenerated.
* generated/spread_i16.c: Regenerated.
* generated/spread_i1.c: Regenerated.
* generated/spread_i2.c: Regenerated.
* generated/spread_i4.c: Regenerated.
* generated/spread_i8.c: Regenerated.
* generated/spread_r10.c: Regenerated.
* generated/spread_r16.c: Regenerated.
* generated/spread_r4.c: Regenerated.
* generated/spread_r8.c: Regenerated.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@175880
138bc75d-0d04-0410-961f-
82ee72b054a4
+2011-07-05 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ * runtime/memory.c (internal_malloc_size): If size is zero,
+ allocate a single byte.
+ * m4/pack.m4 (pack_'rtype_code`): Don't check for zero size
+ for the argument of internal_malloc_size.
+ * m4/spread.m4 (spread_'rtype_code`): Likewise.
+ * m4/eoshift1.m4 (eoshift1): Don't allocate twice. Don't check
+ for zero size for the argument of internal_malloc_size.
+ * m4/eoshift3.m4: Don't check for zero size for the argument of
+ internal_malloc_size.
+ * intrinsics/pack_generic.c (pack_internal): Likewise.
+ (pack_s_internal): Likewise.
+ * intrinsics/cshift0.c (cshift0): Likewise.
+ * intrinsics/spread_generic.c (spread_internal): Likewise.
+ * intrinsics/eoshift0.c (eoshift0): Likewise.
+ * intrinsics/eoshift2.c (eoshift2): Likewise.
+ * generated/eoshift1_16.c: Regenerated.
+ * generated/eoshift1_4.c: Regenerated.
+ * generated/eoshift1_8.c: Regenerated.
+ * generated/eoshift3_16.c: Regenerated.
+ * generated/eoshift3_4.c: Regenerated.
+ * generated/eoshift3_8.c: Regenerated.
+ * generated/pack_c10.c: Regenerated.
+ * generated/pack_c16.c: Regenerated.
+ * generated/pack_c4.c: Regenerated.
+ * generated/pack_c8.c: Regenerated.
+ * generated/pack_i16.c: Regenerated.
+ * generated/pack_i1.c: Regenerated.
+ * generated/pack_i2.c: Regenerated.
+ * generated/pack_i4.c: Regenerated.
+ * generated/pack_i8.c: Regenerated.
+ * generated/pack_r10.c: Regenerated.
+ * generated/pack_r16.c: Regenerated.
+ * generated/pack_r4.c: Regenerated.
+ * generated/pack_r8.c: Regenerated.
+ * generated/spread_c10.c: Regenerated.
+ * generated/spread_c16.c: Regenerated.
+ * generated/spread_c4.c: Regenerated.
+ * generated/spread_c8.c: Regenerated.
+ * generated/spread_i16.c: Regenerated.
+ * generated/spread_i1.c: Regenerated.
+ * generated/spread_i2.c: Regenerated.
+ * generated/spread_i4.c: Regenerated.
+ * generated/spread_i8.c: Regenerated.
+ * generated/spread_r10.c: Regenerated.
+ * generated/spread_r16.c: Regenerated.
+ * generated/spread_r4.c: Regenerated.
+ * generated/spread_r8.c: Regenerated.
+
2011-06-28 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/49479
{
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++)
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))
{
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++)
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))
{
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++)
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))
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))
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))
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))
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 (GFC_COMPLEX_10) * 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 (GFC_COMPLEX_10) * total);
+ return;
}
else
{
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 (GFC_COMPLEX_16) * 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 (GFC_COMPLEX_16) * total);
+ return;
}
else
{
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 (GFC_COMPLEX_4) * 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 (GFC_COMPLEX_4) * total);
+ return;
}
else
{
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 (GFC_COMPLEX_8) * 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 (GFC_COMPLEX_8) * total);
+ return;
}
else
{
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 (GFC_INTEGER_1) * 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 (GFC_INTEGER_1) * total);
+ return;
}
else
{
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 (GFC_INTEGER_16) * 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 (GFC_INTEGER_16) * total);
+ return;
}
else
{
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 (GFC_INTEGER_2) * 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 (GFC_INTEGER_2) * total);
+ return;
}
else
{
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 (GFC_INTEGER_4) * 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 (GFC_INTEGER_4) * total);
+ return;
}
else
{
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 (GFC_INTEGER_8) * 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 (GFC_INTEGER_8) * total);
+ return;
}
else
{
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 (GFC_REAL_10) * 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 (GFC_REAL_10) * total);
+ return;
}
else
{
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 (GFC_REAL_16) * 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 (GFC_REAL_16) * total);
+ return;
}
else
{
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 (GFC_REAL_4) * 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 (GFC_REAL_4) * total);
+ return;
}
else
{
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 (GFC_REAL_8) * 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 (GFC_REAL_8) * total);
+ return;
}
else
{
GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
}
ret->offset = 0;
- if (rs > 0)
- ret->data = internal_malloc_size (rs * sizeof(GFC_COMPLEX_10));
- 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(GFC_COMPLEX_10));
+ if (rs <= 0)
+ return;
}
else
{
GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
}
ret->offset = 0;
- if (rs > 0)
- ret->data = internal_malloc_size (rs * sizeof(GFC_COMPLEX_16));
- 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(GFC_COMPLEX_16));
+ if (rs <= 0)
+ return;
}
else
{
GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
}
ret->offset = 0;
- if (rs > 0)
- ret->data = internal_malloc_size (rs * sizeof(GFC_COMPLEX_4));
- 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(GFC_COMPLEX_4));
+ if (rs <= 0)
+ return;
}
else
{
GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
}
ret->offset = 0;
- if (rs > 0)
- ret->data = internal_malloc_size (rs * sizeof(GFC_COMPLEX_8));
- 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(GFC_COMPLEX_8));
+ if (rs <= 0)
+ return;
}
else
{
GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
}
ret->offset = 0;
- if (rs > 0)
- ret->data = internal_malloc_size (rs * sizeof(GFC_INTEGER_1));
- 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(GFC_INTEGER_1));
+ if (rs <= 0)
+ return;
}
else
{
GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
}
ret->offset = 0;
- if (rs > 0)
- ret->data = internal_malloc_size (rs * sizeof(GFC_INTEGER_16));
- 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(GFC_INTEGER_16));
+ if (rs <= 0)
+ return;
}
else
{
GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
}
ret->offset = 0;
- if (rs > 0)
- ret->data = internal_malloc_size (rs * sizeof(GFC_INTEGER_2));
- 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(GFC_INTEGER_2));
+ if (rs <= 0)
+ return;
}
else
{
GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
}
ret->offset = 0;
- if (rs > 0)
- ret->data = internal_malloc_size (rs * sizeof(GFC_INTEGER_4));
- 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(GFC_INTEGER_4));
+ if (rs <= 0)
+ return;
}
else
{
GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
}
ret->offset = 0;
- if (rs > 0)
- ret->data = internal_malloc_size (rs * sizeof(GFC_INTEGER_8));
- 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(GFC_INTEGER_8));
+ if (rs <= 0)
+ return;
}
else
{
GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
}
ret->offset = 0;
- if (rs > 0)
- ret->data = internal_malloc_size (rs * sizeof(GFC_REAL_10));
- 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(GFC_REAL_10));
+ if (rs <= 0)
+ return;
}
else
{
GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
}
ret->offset = 0;
- if (rs > 0)
- ret->data = internal_malloc_size (rs * sizeof(GFC_REAL_16));
- 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(GFC_REAL_16));
+ if (rs <= 0)
+ return;
}
else
{
GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
}
ret->offset = 0;
- if (rs > 0)
- ret->data = internal_malloc_size (rs * sizeof(GFC_REAL_4));
- 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(GFC_REAL_4));
+ if (rs <= 0)
+ return;
}
else
{
GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
}
ret->offset = 0;
- if (rs > 0)
- ret->data = internal_malloc_size (rs * sizeof(GFC_REAL_8));
- 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(GFC_REAL_8));
+ if (rs <= 0)
+ return;
}
else
{
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))
{
}
- 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))
{
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);
}
}
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 (size * 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 (size * total);
+ return; /* In this case, nothing remains to be done. */
}
else
{
ret->offset = 0;
+ ret->data = internal_malloc_size (size * total);
+
if (total == 0)
- {
- ret->data = internal_malloc_size (1);
- return;
- }
- else
- ret->data = internal_malloc_size (size * total);
+ return;
}
rstride0 = GFC_DESCRIPTOR_STRIDE_BYTES(ret,0);
GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
}
ret->offset = 0;
- if (rs > 0)
- ret->data = internal_malloc_size (rs * size);
- else
- {
- ret->data = internal_malloc_size (1);
- return;
- }
+ ret->data = internal_malloc_size (rs * size);
+
+ if (rs <= 0)
+ return;
}
else
{
{
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++)
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))
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))
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
{
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
{
void *
internal_malloc_size (size_t size)
{
- if (size == 0)
- return NULL;
+ if (unlikely (size == 0))
+ size = 1;
return get_mem (size);
}