~ubuntu-branches/ubuntu/gutsy/plotutils/gutsy

« back to all changes in this revision

Viewing changes to libplot/g_xmalloc.c

  • Committer: Bazaar Package Importer
  • Author(s): Floris Bruynooghe
  • Date: 2007-05-10 19:48:54 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070510194854-mrr3lgwzpxd8hovo
Tags: 2.5-2
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the GNU plotutils package.  Copyright (C) 1995,
 
2
   1996, 1997, 1998, 1999, 2000, 2005, Free Software Foundation, Inc.
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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. */
 
18
 
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). */
6
24
#include "extern.h"
7
25
 
8
26
/* wrapper for malloc() */
9
 
voidptr_t 
10
 
#ifdef _HAVE_PROTOS
11
 
_plot_xmalloc (size_t size)
12
 
#else
13
 
_plot_xmalloc (size)
14
 
     size_t size;
15
 
#endif
 
27
void * 
 
28
_pl_xmalloc (size_t size)
16
29
{
17
 
  voidptr_t p;
 
30
  void * p;
18
31
 
19
 
  p = (voidptr_t) malloc (size);
20
 
  if (p == (voidptr_t)NULL)
 
32
  p = (void *) malloc (size);
 
33
  if (p == (void *)NULL)
21
34
    {
22
35
      fputs ("libplot: ", stderr);
23
36
      perror ("out of memory");
32
45
}
33
46
 
34
47
/* wrapper for calloc() */
35
 
voidptr_t 
36
 
#ifdef _HAVE_PROTOS
37
 
_plot_xcalloc (size_t nmemb, size_t size)
38
 
#else
39
 
_plot_xcalloc (nmemb, size)
40
 
     size_t nmemb, size;
41
 
#endif
 
48
void * 
 
49
_pl_xcalloc (size_t nmemb, size_t size)
42
50
{
43
 
  voidptr_t p;
 
51
  void * p;
44
52
 
45
 
  p = (voidptr_t) calloc (nmemb, size);
46
 
  if (p == (voidptr_t)NULL)
 
53
  p = (void *) calloc (nmemb, size);
 
54
  if (p == (void *)NULL)
47
55
    {
48
56
      fputs ("libplot: ", stderr);
49
57
      perror ("out of memory");
58
66
}
59
67
 
60
68
/* wrapper for realloc() */
61
 
voidptr_t 
62
 
#ifdef _HAVE_PROTOS
63
 
_plot_xrealloc (voidptr_t p, size_t size)
64
 
#else
65
 
_plot_xrealloc (p, size)
66
 
     voidptr_t p;
67
 
     size_t size;
68
 
#endif
 
69
void * 
 
70
_pl_xrealloc (void * p, size_t size)
69
71
{
70
 
  voidptr_t q;
 
72
  void * q;
71
73
 
72
 
  q = (voidptr_t) realloc (p, size);
73
 
  if (q == (voidptr_t)NULL)
 
74
  q = (void *) realloc (p, size);
 
75
  if (q == (void *)NULL)
74
76
    {
75
77
      fputs ("libplot: ", stderr);
76
78
      perror ("out of memory");