PR 78534, 83704 Handle large formatted I/O
[gcc.git] / libgfortran / runtime / convert_char.c
index aa43d9796a31d33c2c8e6b187e20a3ea0ca00de8..846fcd6f174755e417f37ebff3f337d8ffc6692a 100644 (file)
@@ -1,5 +1,5 @@
 /* Runtime conversion of strings from one character kind to another.
-   Copyright 2008, 2009, 2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2018 Free Software Foundation, Inc.
 
 This file is part of the GNU Fortran runtime library (libgfortran).
 
@@ -24,9 +24,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #include "libgfortran.h"
 
-#include <stdlib.h>
-#include <string.h>
-
 
 extern void convert_char1_to_char4 (gfc_char4_t **, gfc_charlen_type,
                                    const unsigned char *);
@@ -44,7 +41,7 @@ convert_char1_to_char4 (gfc_char4_t **dst, gfc_charlen_type len,
   gfc_charlen_type i, l;
 
   l = len > 0 ? len : 0;
-  *dst = xmalloc ((l + 1) * sizeof (gfc_char4_t));
+  *dst = xmallocarray ((l + 1), sizeof (gfc_char4_t));
 
   for (i = 0; i < l; i++)
     (*dst)[i] = src[i];
@@ -60,7 +57,7 @@ convert_char4_to_char1 (unsigned char **dst, gfc_charlen_type len,
   gfc_charlen_type i, l;
 
   l = len > 0 ? len : 0;
-  *dst = xmalloc ((l + 1) * sizeof (unsigned char));
+  *dst = xmalloc (l + 1);
 
   for (i = 0; i < l; i++)
     (*dst)[i] = src[i];