diff options
author | Janne Blomqvist <jb@gcc.gnu.org> | 2012-03-25 08:48:49 +0300 |
---|---|---|
committer | Janne Blomqvist <jb@gcc.gnu.org> | 2012-03-25 08:48:49 +0300 |
commit | f4471acbe3a0e4aee9aa8144898c593ff4e7b595 (patch) | |
tree | 685cb6240f35fb0058480526772367ef510d1cba /libgfortran/io/unit.c | |
parent | 0651865170b953c49b8acce8ad6de0143c00fc06 (diff) | |
download | gcc-f4471acbe3a0e4aee9aa8144898c593ff4e7b595.zip gcc-f4471acbe3a0e4aee9aa8144898c593ff4e7b595.tar.gz gcc-f4471acbe3a0e4aee9aa8144898c593ff4e7b595.tar.bz2 |
Use calloc instead of malloc and memset.
2012-03-25 Janne Blomqvist <jb@gcc.gnu.org>
* runtime/memory.c (xcalloc): New function.
* libgfortran.h (xcalloc): New prototype.
* io/list_read.c (push_char): Use xcalloc instead of get_mem and
memset.
(l_push_char): Likewise.
* io/unit.c (insert_unit): Likewise.
(get_internal_unit): Likewise.
* io/unix.c (open_internal): Likewise.
(open_internal4): Likewise.
(fd_to_stream): Likewise.
From-SVN: r185773
Diffstat (limited to 'libgfortran/io/unit.c')
-rw-r--r-- | libgfortran/io/unit.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c index 819d0e9..5fe9eb2 100644 --- a/libgfortran/io/unit.c +++ b/libgfortran/io/unit.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2005, 2007, 2008, 2009, 2010, 2011 +/* Copyright (C) 2002, 2003, 2005, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. Contributed by Andy Vaught F2003 I/O support contributed by Jerry DeLisle @@ -188,8 +188,7 @@ insert (gfc_unit *new, gfc_unit *t) static gfc_unit * insert_unit (int n) { - gfc_unit *u = get_mem (sizeof (gfc_unit)); - memset (u, '\0', sizeof (gfc_unit)); + gfc_unit *u = xcalloc (1, sizeof (gfc_unit)); u->unit_number = n; #ifdef __GTHREAD_MUTEX_INIT { @@ -385,14 +384,8 @@ get_internal_unit (st_parameter_dt *dtp) /* Allocate memory for a unit structure. */ - iunit = get_mem (sizeof (gfc_unit)); - if (iunit == NULL) - { - generate_error (&dtp->common, LIBERROR_INTERNAL_UNIT, NULL); - return NULL; - } + iunit = xcalloc (1, sizeof (gfc_unit)); - memset (iunit, '\0', sizeof (gfc_unit)); #ifdef __GTHREAD_MUTEX_INIT { __gthread_mutex_t tmp = __GTHREAD_MUTEX_INIT; |