1
/* This file is part of the GNU libxmi package. Copyright (C) 1998, 1999,
2
2000, 2005, Free Software Foundation, Inc.
4
The GNU libxmi 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 libxmi 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. The tests for zero
2
20
size, etc., are necessitated by the way in which the original X11
3
21
scan-conversion code was written. */
10
28
#include "mi_api.h"
12
30
/* wrapper for malloc() */
15
32
mi_xmalloc (size_t size)
24
return (voidptr_t)NULL;
26
p = (voidptr_t) malloc (size);
27
if (p == (voidptr_t)NULL)
39
p = (void *) malloc (size);
40
if (p == (void *)NULL)
29
42
fprintf (stderr, "libxmi: ");
30
43
perror ("out of memory");
36
49
/* wrapper for calloc() */
39
51
mi_xcalloc (size_t nmemb, size_t size)
41
mi_xcalloc (nmemb, size)
48
return (voidptr_t)NULL;
50
p = (voidptr_t) calloc (nmemb, size);
51
if (p == (voidptr_t)NULL)
58
p = (void *) calloc (nmemb, size);
59
if (p == (void *)NULL)
53
61
fprintf (stderr, "libxmi: ");
54
62
perror ("out of memory");
60
68
/* wrapper for realloc() */
63
mi_xrealloc (voidptr_t p, size_t size)
70
mi_xrealloc (void * p, size_t size)
71
73
return mi_xmalloc (size);
77
return (voidptr_t)NULL;
80
p = (voidptr_t) realloc (p, size);
81
if (p == (voidptr_t)NULL)
82
p = (void *) realloc (p, size);
83
if (p == (void *)NULL)
83
85
fprintf (stderr, "libxmi: ");
84
86
perror ("out of memory");