]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgfortran/runtime/memory.c
Update copyright years in libgfortran.
[thirdparty/gcc.git] / libgfortran / runtime / memory.c
CommitLineData
8b6dba81 1/* Memory management routines.
e3c063ce 2 Copyright (C) 2002-2013 Free Software Foundation, Inc.
6de9cd9a
DN
3 Contributed by Paul Brook <paul@nowt.org>
4
bb408e87 5This file is part of the GNU Fortran runtime library (libgfortran).
6de9cd9a 6
57dea9f6
TM
7Libgfortran is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public
6de9cd9a 9License as published by the Free Software Foundation; either
748086b7 10version 3 of the License, or (at your option) any later version.
57dea9f6
TM
11
12Libgfortran is distributed in the hope that it will be useful,
6de9cd9a
DN
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57dea9f6 15GNU General Public License for more details.
6de9cd9a 16
748086b7
JJ
17Under Section 7 of GPL version 3, you are granted additional
18permissions described in the GCC Runtime Library Exception, version
193.1, as published by the Free Software Foundation.
20
21You should have received a copy of the GNU General Public License and
22a copy of the GCC Runtime Library Exception along with this program;
23see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24<http://www.gnu.org/licenses/>. */
6de9cd9a 25
6de9cd9a 26#include "libgfortran.h"
36ae8a61 27#include <stdlib.h>
6de9cd9a 28
6de9cd9a 29
6de9cd9a 30void *
1a0fd3d3 31xmalloc (size_t n)
6de9cd9a
DN
32{
33 void *p;
34
1a0fd3d3
JB
35 if (n == 0)
36 n = 1;
37
38 p = malloc (n);
39
6de9cd9a
DN
40 if (p == NULL)
41 os_error ("Memory allocation failed");
42
43 return p;
44}
45
46
f4471acb
JB
47/* calloc wrapper that aborts on error. */
48
49void *
50xcalloc (size_t nmemb, size_t size)
51{
52 if (nmemb * size == 0)
53 nmemb = size = 1;
54
55 void *p = calloc (nmemb, size);
56 if (!p)
57 os_error ("Allocating cleared memory failed");
58
59 return p;
60}