GRASS Programmer's Manual
6.4.2(2012)
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
gis/alloc.c
Go to the documentation of this file.
1
17
#include <stdlib.h>
18
#include <grass/gis.h>
19
#include <grass/glocale.h>
20
21
34
void
*
G__malloc
(
const
char
*file,
int
line,
size_t
n)
35
{
36
void
*buf;
37
38
if
(n <= 0)
39
n = 1;
/* make sure we get a valid request */
40
41
buf = malloc(n);
42
if
(!buf)
43
G_fatal_error
(_(
"G_malloc: unable to allocate %lu bytes at %s:%d"
),
44
(
unsigned
long
) n, file, line);
45
46
return
buf;
47
}
48
65
void
*
G__calloc
(
const
char
*file,
int
line,
size_t
m,
size_t
n)
66
{
67
void
*buf;
68
69
if
(m <= 0)
70
m = 1;
/* make sure we get a valid requests */
71
if
(n <= 0)
72
n = 1;
73
74
buf = calloc(m, n);
75
if
(!buf)
76
G_fatal_error
(_(
"G_calloc: unable to allocate %lu * %lu bytes at %s:%d"
),
77
(
unsigned
long
) m, (
unsigned
long
) n, file, line);
78
79
return
buf;
80
}
81
82
103
void
*
G__realloc
(
const
char
*file,
int
line,
void
*buf,
size_t
n)
104
{
105
if
(n <= 0)
106
n = 1;
/* make sure we get a valid request */
107
108
if
(!buf)
109
buf = malloc(n);
110
else
111
buf = realloc(buf, n);
112
113
if
(!buf)
114
G_fatal_error
(_(
"G_realloc: unable to allocate %lu bytes at %s:%d"
),
115
(
unsigned
long
) n, file, line);
116
117
return
buf;
118
}
119
120
127
void
G_free
(
void
*buf)
128
{
129
free(buf);
130
}
lib
gis
alloc.c
Generated on Sun Mar 16 2014 05:07:42 for GRASS Programmer's Manual by
1.8.1.2