GRASS GIS 7 Programmer's Manual
7.0.5(2016)-r00000
rowio/setup.c
Go to the documentation of this file.
1
14
#include <stdio.h>
15
#include <stdlib.h>
16
#include <grass/gis.h>
17
#include <grass/glocale.h>
18
#include <grass/rowio.h>
19
44
int
Rowio_setup
(ROWIO * R,
45
int
fd,
int
nrows,
int
len,
46
int
(*getrow) (
int
,
void
*,
int
,
int
),
47
int
(*putrow) (
int
,
const
void
*,
int
,
int
))
48
{
49
int
i;
50
51
R->getrow = getrow;
52
R->putrow = putrow;
53
R->nrows = nrows;
54
R->len = len;
55
R->cur = -1;
56
R->buf =
NULL
;
57
R->fd = fd;
58
59
R->rcb = (
struct
ROWIO_RCB *) G_malloc(nrows *
sizeof
(
struct
ROWIO_RCB));
60
if
(R->rcb ==
NULL
) {
61
G_warning
(_(
"Out of memory"
));
62
return
-1;
63
}
64
for
(i = 0; i < nrows; i++) {
65
R->rcb[i].buf = G_malloc(len);
66
if
(R->rcb[i].buf ==
NULL
) {
67
G_warning
(_(
"Out of memory"
));
68
return
-1;
69
}
70
R->rcb[i].row = -1;
/* mark not used */
71
}
72
return
1;
73
}
NULL
#define NULL
Definition:
ccmath.h:32
Rowio_setup
int Rowio_setup(ROWIO *R, int fd, int nrows, int len, int(*getrow)(int, void *, int, int), int(*putrow)(int, const void *, int, int))
Configure rowio structure.
Definition:
rowio/setup.c:44
G_warning
void G_warning(const char *msg,...)
Print a warning message to stderr.
Definition:
gis/error.c:203
rowio
setup.c
Generated on Sun Oct 2 2016 20:26:53 for GRASS GIS 7 Programmer's Manual by
1.8.12