GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
segment/init.c File Reference
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <grass/segment.h>
Include dependency graph for segment/init.c:

Go to the source code of this file.

Functions

int segment_init (SEGMENT *SEG, int fd, int nseg)
 Initialize segment structure. More...
 

Function Documentation

int segment_init ( SEGMENT *  SEG,
int  fd,
int  nseg 
)

Initialize segment structure.

Initializes the seg structure. The file on fd is a segment file created by segment_format() and must be open for reading and writing. The segment file configuration parameters nrows, ncols, srows, scols, and len, as written to the file by segment_format(), are read from the file and stored in the seg structure. nsegs specifies the number of segments that will be retained in memory. The minimum value allowed is 1.

Note: The size of a segment is scols*srows*len plus a few bytes for managing each segment.

Parameters
[in,out]segsegment
[in]fdfile descriptor
[in]nsegsnumber of segments to remain in memory
Returns
1 if successful
-1 if unable to seek or read segment file
-2 if out of memory

Definition at line 56 of file segment/init.c.

References errno, fd, G_warning(), and segment_setup().

Referenced by main().