]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgfortran/generated/spread_i1.c
Update copyright years.
[thirdparty/gcc.git] / libgfortran / generated / spread_i1.c
index 0e654eb75b80dd6804963fb21ffe7668e1ea83e9..fc140e25f68bf799b7a6315ac3b3e3c85bcb7c0d 100644 (file)
@@ -1,5 +1,5 @@
 /* Special implementation of the SPREAD intrinsic
-   Copyright 2008, 2009, 2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2023 Free Software Foundation, Inc.
    Contributed by Thomas Koenig <tkoenig@gcc.gnu.org>, based on
    spread_generic.c written by Paul Brook <paul@nowt.org>
 
@@ -25,8 +25,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
 #include "libgfortran.h"
-#include <stdlib.h>
-#include <assert.h>
 #include <string.h>
 
 
@@ -74,7 +72,8 @@ spread_i1 (gfc_array_i1 *ret, const gfc_array_i1 *source,
 
       /* The front end has signalled that we need to populate the
         return array descriptor.  */
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->dtype.rank = rrank;
+
       dim = 0;
       rs = 1;
       for (n = 0; n < rrank; n++)
@@ -101,8 +100,8 @@ spread_i1 (gfc_array_i1 *ret, const gfc_array_i1 *source,
        }
       ret->offset = 0;
 
-      /* internal_malloc_size allocates a single byte for zero size.  */
-      ret->base_addr = internal_malloc_size (rs * sizeof(GFC_INTEGER_1));
+      /* xmallocarray allocates a single byte for zero size.  */
+      ret->base_addr = xmallocarray (rs, sizeof(GFC_INTEGER_1));
       if (rs <= 0)
         return;
     }
@@ -229,10 +228,8 @@ spread_i1 (gfc_array_i1 *ret, const gfc_array_i1 *source,
 
 void
 spread_scalar_i1 (gfc_array_i1 *ret, const GFC_INTEGER_1 *source,
-                       const index_type along, const index_type pncopies)
+                       const index_type along, const index_type ncopies)
 {
-  int n;
-  int ncopies = pncopies;
   GFC_INTEGER_1 * restrict dest;
   index_type stride;
 
@@ -244,7 +241,7 @@ spread_scalar_i1 (gfc_array_i1 *ret, const GFC_INTEGER_1 *source,
 
   if (ret->base_addr == NULL)
     {
-      ret->base_addr = internal_malloc_size (ncopies * sizeof (GFC_INTEGER_1));
+      ret->base_addr = xmallocarray (ncopies, sizeof (GFC_INTEGER_1));
       ret->offset = 0;
       GFC_DIMENSION_SET(ret->dim[0], 0, ncopies - 1, 1);
     }
@@ -258,7 +255,7 @@ spread_scalar_i1 (gfc_array_i1 *ret, const GFC_INTEGER_1 *source,
   dest = ret->base_addr;
   stride = GFC_DESCRIPTOR_STRIDE(ret,0);
 
-  for (n = 0; n < ncopies; n++)
+  for (index_type n = 0; n < ncopies; n++)
     {
       *dest = *source;
       dest += stride;