GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71769
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
struct_alloc.c File Reference

Vector library - allocate and zero array space (lower level functions) More...

#include <stdlib.h>
#include <grass/vector.h>
#include <grass/glocale.h>
Include dependency graph for struct_alloc.c:

Go to the source code of this file.

Functions

struct P_nodedig_alloc_node ()
 Allocate new node structure. More...
 
void dig_free_node (struct P_node *Node)
 Free node structure. More...
 
int dig_node_alloc_line (struct P_node *node, int add)
 Allocate space in P_node struct. More...
 
int dig_alloc_nodes (struct Plus_head *Plus, int add)
 Reallocate array of pointers to nodes. More...
 
struct P_linedig_alloc_line ()
 Allocate new line structure. More...
 
void * dig_alloc_topo (char type)
 Allocate new topo struct. More...
 
void dig_free_line (struct P_line *Line)
 Free line structure. More...
 
int dig_alloc_lines (struct Plus_head *Plus, int add)
 Reallocate array of pointers to lines. More...
 
int dig_alloc_areas (struct Plus_head *Plus, int add)
 Reallocate array of pointers to areas. More...
 
int dig_alloc_isles (struct Plus_head *Plus, int add)
 Reallocate array of pointers to isles. More...
 
struct P_areadig_alloc_area ()
 Allocate new area structure. More...
 
void dig_free_area (struct P_area *Area)
 Free area structure. More...
 
struct P_isledig_alloc_isle ()
 Allocate new isle structure. More...
 
void dig_free_isle (struct P_isle *Isle)
 Free isle structure. More...
 
int dig_alloc_points (struct line_pnts *points, int num)
 allocate room for 'num' X and Y arrays in struct line_pnts More...
 
int dig_alloc_cats (struct line_cats *cats, int num)
 Allocate room for 'num' fields and category arrays in struct line_cats. More...
 
int dig_area_alloc_line (struct P_area *area, int add)
 allocate space in P_area for add new lines More...
 
int dig_area_alloc_isle (struct P_area *area, int add)
 Allocate space in P_area for add new isles. More...
 
int dig_isle_alloc_line (struct P_isle *isle, int add)
 Allocate space in P_isle for add new lines. More...
 
int dig_out_of_memory ()
 For now just print message and return error code. More...
 

Detailed Description

Vector library - allocate and zero array space (lower level functions)

Lower level functions for reading/writing/manipulating vectors.

These routines all eventually call calloc() to allocate and zero the new space. BUT It is not necessarily safe to assume that the memory will be zero. The next memory location asked for could have been previously used and not zeroed. (e.g. compress()).

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
CERL (probably Dave Gerdes)
Radim Blazek

Definition in file struct_alloc.c.

Function Documentation

struct P_area* dig_alloc_area ( )

Allocate new area structure.

Returns
pointer to allocated P_area struct
NULL on error

Definition at line 263 of file struct_alloc.c.

References G_zero(), and NULL.

Referenced by dig_add_area(), and dig_Rd_P_area().

int dig_alloc_areas ( struct Plus_head Plus,
int  add 
)

Reallocate array of pointers to areas.

Parameters
Pluspointer to Plus_head structure
addspace for 'add' number of areas is added
Returns
0 on success
-1 on error

Definition at line 215 of file struct_alloc.c.

References Plus_head::alloc_areas, Plus_head::Area, and NULL.

Referenced by dig_add_area(), and dig_load_plus().

int dig_alloc_cats ( struct line_cats cats,
int  num 
)

Allocate room for 'num' fields and category arrays in struct line_cats.

Parameters
catspointer to line_cats struct
numnumber of cats
Returns
0 on success
returns -1 on out of memory

Definition at line 380 of file struct_alloc.c.

References line_cats::alloc_cats, line_cats::cat, dig__alloc_space(), dig_out_of_memory(), and line_cats::field.

Referenced by Vect_cat_set().

struct P_isle* dig_alloc_isle ( )

Allocate new isle structure.

Returns
pointer to allocated P_isle struct
NULL on error

Definition at line 298 of file struct_alloc.c.

References G_zero(), and NULL.

Referenced by dig_add_isle(), and dig_Rd_P_isle().

int dig_alloc_isles ( struct Plus_head Plus,
int  add 
)

Reallocate array of pointers to isles.

Parameters
Pluspointer to Plus_head structure
addspace for 'add' number of isles is added.
Returns
0 on success
-1 on error

Definition at line 240 of file struct_alloc.c.

References Plus_head::alloc_isles, G_debug(), Plus_head::Isle, and NULL.

Referenced by dig_add_isle(), and dig_load_plus().

struct P_line* dig_alloc_line ( )

Allocate new line structure.

Returns
pointer to allocated P_node struct
NULL on error

Definition at line 124 of file struct_alloc.c.

References G_zero(), and NULL.

Referenced by dig_Rd_P_line().

int dig_alloc_lines ( struct Plus_head Plus,
int  add 
)

Reallocate array of pointers to lines.

Parameters
Pluspointer to Plus_head structure
addspace for 'add' number of lines is added.
Returns
0 on success
-1 on error

Definition at line 190 of file struct_alloc.c.

References Plus_head::alloc_lines, Plus_head::Line, and NULL.

Referenced by dig_add_line(), and dig_load_plus().

struct P_node* dig_alloc_node ( )

Allocate new node structure.

Returns
pointer to allocated P_node struct
NULL on error

Definition at line 30 of file struct_alloc.c.

References G_zero(), and NULL.

Referenced by dig_add_node(), and dig_Rd_P_node().

int dig_alloc_nodes ( struct Plus_head Plus,
int  add 
)

Reallocate array of pointers to nodes.

Parameters
Pluspointer to Plus_head structure
addnumber of nodes to be added
Returns
0 on success
-1 on error

Definition at line 102 of file struct_alloc.c.

References Plus_head::alloc_nodes, Plus_head::Node, and NULL.

Referenced by dig_add_node(), and dig_load_plus().

int dig_alloc_points ( struct line_pnts points,
int  num 
)

allocate room for 'num' X and Y arrays in struct line_pnts

Parameters
pointspointer to line_pnts struct
numnumber of points
Returns
0 on success
returns -1 on out of memory

Definition at line 333 of file struct_alloc.c.

References line_pnts::alloc_points, dig__alloc_space(), dig_out_of_memory(), line_pnts::x, line_pnts::y, and line_pnts::z.

Referenced by dig_get_poly_points(), Vect_append_point(), Vect_append_points(), Vect_copy_xyz_to_pnts(), and Vect_line_insert_point().

void* dig_alloc_topo ( char  type)

Allocate new topo struct.

Parameters
typeto of struct to allocate

Definition at line 142 of file struct_alloc.c.

References GV_BOUNDARY, GV_CENTROID, GV_FACE, GV_KERNEL, GV_LINE, and NULL.

Referenced by dig_Rd_P_line().

int dig_area_alloc_isle ( struct P_area area,
int  add 
)

Allocate space in P_area for add new isles.

Parameters
areapointer to P_area struct
addnumber of isle to be added
Returns
0 on success
-1 on error

Definition at line 442 of file struct_alloc.c.

References P_area::alloc_isles, G_debug(), P_area::isles, NULL, and num.

Referenced by dig_area_add_isle(), and dig_Rd_P_area().

int dig_area_alloc_line ( struct P_area area,
int  add 
)

allocate space in P_area for add new lines

Parameters
areapointer to P_area struct
addnumber of lines to be added
Returns
0 on success
-1 on error

Definition at line 416 of file struct_alloc.c.

References P_area::alloc_lines, P_area::lines, NULL, and num.

Referenced by dig_add_area(), and dig_Rd_P_area().

void dig_free_area ( struct P_area Area)

Free area structure.

Parameters
Areapointer to P_area struct to be freed

Definition at line 281 of file struct_alloc.c.

References P_area::alloc_isles, P_area::alloc_lines, free(), G_free(), P_area::isles, and P_area::lines.

Referenced by dig_del_area(), and dig_free_plus_areas().

void dig_free_isle ( struct P_isle Isle)

Free isle structure.

Parameters
Islepointer to P_isle struct to be freed

Definition at line 316 of file struct_alloc.c.

References P_isle::alloc_lines, G_free(), and P_isle::lines.

Referenced by dig_del_isle(), and dig_free_plus_isles().

void dig_free_line ( struct P_line Line)

Free line structure.

Parameters
pointerto P_line struct to be freed

Definition at line 174 of file struct_alloc.c.

References G_free(), and P_line::topo.

Referenced by dig_del_line(), and dig_free_plus_lines().

void dig_free_node ( struct P_node Node)

Free node structure.

Parameters
Nodepointer to P_node struct to be freed

Definition at line 48 of file struct_alloc.c.

References P_node::alloc_lines, P_node::angles, G_free(), and P_node::lines.

Referenced by dig_del_line(), and dig_free_plus_nodes().

int dig_isle_alloc_line ( struct P_isle isle,
int  add 
)

Allocate space in P_isle for add new lines.

Parameters
islepointer to P_area struct
addnumber of isle to be added
Returns
0 on success
-1 on error

Definition at line 468 of file struct_alloc.c.

References P_isle::alloc_lines, G_debug(), P_isle::lines, NULL, and num.

Referenced by dig_add_isle(), and dig_Rd_P_isle().

int dig_node_alloc_line ( struct P_node node,
int  add 
)

Allocate space in P_node struct.

Lines and angles arrays to add 'add' more lines

Parameters
nodepointer to P_node struct
addnumber lines to be added
Returns
0 on success
-1 on error

Definition at line 69 of file struct_alloc.c.

References P_node::alloc_lines, P_node::angles, G_debug(), P_node::lines, P_node::n_lines, NULL, and num.

Referenced by dig_node_add_line(), and dig_Rd_P_node().

int dig_out_of_memory ( void  )

For now just print message and return error code.

Definition at line 489 of file struct_alloc.c.

References _, and G_warning().

Referenced by dig_alloc_cats(), dig_alloc_points(), and dig_build_area_with_line().