1
/* This file is part of the GNU plotutils package. Copyright (C) 1995,
2
1996, 1997, 1998, 1999, 2000, 2005, Free Software Foundation, Inc.
4
The GNU plotutils package is free software. You may redistribute it
5
and/or modify it under the terms of the GNU General Public License as
6
published by the Free Software foundation; either version 2, or (at your
7
option) any later version.
9
The GNU plotutils package is distributed in the hope that it will be
10
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
General Public License for more details.
14
You should have received a copy of the GNU General Public License along
15
with the GNU plotutils package; see the file COPYING. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
17
Boston, MA 02110-1301, USA. */
1
19
/* Wrappers for standard storage allocation functions, for
2
20
libplot/libplotter with the exception of the libxmi scan conversion
3
21
module, which has its own more complicated versions (see mi_alloc.c). */
8
26
/* wrapper for malloc() */
11
_plot_xmalloc (size_t size)
28
_pl_xmalloc (size_t size)
19
p = (voidptr_t) malloc (size);
20
if (p == (voidptr_t)NULL)
32
p = (void *) malloc (size);
33
if (p == (void *)NULL)
22
35
fputs ("libplot: ", stderr);
23
36
perror ("out of memory");
34
47
/* wrapper for calloc() */
37
_plot_xcalloc (size_t nmemb, size_t size)
39
_plot_xcalloc (nmemb, size)
49
_pl_xcalloc (size_t nmemb, size_t size)
45
p = (voidptr_t) calloc (nmemb, size);
46
if (p == (voidptr_t)NULL)
53
p = (void *) calloc (nmemb, size);
54
if (p == (void *)NULL)
48
56
fputs ("libplot: ", stderr);
49
57
perror ("out of memory");
60
68
/* wrapper for realloc() */
63
_plot_xrealloc (voidptr_t p, size_t size)
65
_plot_xrealloc (p, size)
70
_pl_xrealloc (void * p, size_t size)
72
q = (voidptr_t) realloc (p, size);
73
if (q == (voidptr_t)NULL)
74
q = (void *) realloc (p, size);
75
if (q == (void *)NULL)
75
77
fputs ("libplot: ", stderr);
76
78
perror ("out of memory");