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
db/dbmi_base/alloc.c
Go to the documentation of this file.
1
#include <string.h>
2
#include <stdlib.h>
3
#include <grass/dbmi.h>
4
11
char
*
db_store
(
const
char
*
s
)
12
{
13
char
*a;
14
15
a =
db_malloc
(strlen(s) + 1);
16
if
(a)
17
strcpy(a, s);
18
return
a;
19
}
20
27
void
*
db_malloc
(
int
n)
28
{
29
void
*
s
;
30
31
if
(n <= 0)
32
n = 1;
33
s = malloc((
unsigned
int
)n);
34
if
(s ==
NULL
)
35
db_memory_error
();
36
return
s
;
37
}
38
45
void
*
db_calloc
(
int
n,
int
m)
46
{
47
void
*
s
;
48
49
if
(n <= 0)
50
n = 1;
51
if
(m <= 0)
52
m = 1;
53
s = calloc((
unsigned
int
)n, (
unsigned
int
)m);
54
if
(s ==
NULL
)
55
db_memory_error
();
56
return
s
;
57
}
58
65
void
*
db_realloc
(
void
*
s
,
int
n)
66
{
67
if
(n <= 0)
68
n = 1;
69
if
(s ==
NULL
)
70
s = malloc((
unsigned
int
)n);
71
else
72
s = realloc(s, (
unsigned
int
)n);
73
if
(s ==
NULL
)
74
db_memory_error
();
75
return
s
;
76
}
77
84
void
*
db_free
(
void
*
s
)
85
{
86
free(s);
87
}
lib
db
dbmi_base
alloc.c
Generated on Sun Mar 16 2014 05:07:42 for GRASS Programmer's Manual by
1.8.1.2