GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-535c39c9fc
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 (void)
 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 (void)
 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 (void)
 Allocate new area structure. More...
 
void dig_free_area (struct P_area *Area)
 Free area structure. More...
 
struct P_isledig_alloc_isle (void)
 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 (void)
 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

◆ dig_alloc_area()

struct P_area* dig_alloc_area ( void  )

Allocate new area structure.

Returns
pointer to allocated P_area struct
NULL on error

Definition at line 266 of file struct_alloc.c.

References G_malloc, G_zero(), and NULL.

Referenced by dig_Rd_P_area().

◆ dig_alloc_areas()

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 218 of file struct_alloc.c.

Referenced by dig_load_plus().

◆ dig_alloc_cats()

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().

◆ dig_alloc_isle()

struct P_isle* dig_alloc_isle ( void  )

Allocate new isle structure.

Returns
pointer to allocated P_isle struct
NULL on error

Definition at line 301 of file struct_alloc.c.

References G_malloc, G_zero(), and NULL.

Referenced by dig_Rd_P_isle().

◆ dig_alloc_isles()

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 243 of file struct_alloc.c.

Referenced by dig_load_plus().

◆ dig_alloc_line()

struct P_line* dig_alloc_line ( void  )

Allocate new line structure.

Returns
pointer to allocated P_node struct
NULL on error

Definition at line 127 of file struct_alloc.c.

References G_malloc, G_zero(), and NULL.

Referenced by dig_Rd_P_line().

◆ dig_alloc_lines()

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 193 of file struct_alloc.c.

Referenced by dig_load_plus(), and Vect__load_map_lines_pg().

◆ dig_alloc_node()

struct P_node* dig_alloc_node ( void  )

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_malloc, G_zero(), and NULL.

Referenced by dig_add_node(), and dig_Rd_P_node().

◆ dig_alloc_nodes()

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 105 of file struct_alloc.c.

Referenced by dig_add_node(), dig_load_plus(), and Vect__load_map_nodes_pg().

◆ dig_alloc_points()

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 336 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.

◆ dig_alloc_topo()

void* dig_alloc_topo ( char  type)

Allocate new topo struct.

Parameters
typeto of struct to allocate

Definition at line 145 of file struct_alloc.c.

Referenced by dig_Rd_P_line().

◆ dig_area_alloc_isle()

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 440 of file struct_alloc.c.

Referenced by dig_Rd_P_area().

◆ dig_area_alloc_line()

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 414 of file struct_alloc.c.

Referenced by dig_Rd_P_area().

◆ dig_free_area()

void dig_free_area ( struct P_area Area)

Free area structure.

Parameters
Areapointer to P_area struct to be freed

Definition at line 284 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_free_plus_areas().

◆ dig_free_isle()

void dig_free_isle ( struct P_isle Isle)

Free isle structure.

Parameters
Islepointer to P_isle struct to be freed

Definition at line 319 of file struct_alloc.c.

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

Referenced by dig_free_plus_isles().

◆ dig_free_line()

void dig_free_line ( struct P_line Line)

Free line structure.

Parameters
pointerto P_line struct to be freed

Definition at line 177 of file struct_alloc.c.

References G_free(), and P_line::topo.

Referenced by dig_free_plus_lines().

◆ dig_free_node()

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_free_plus_nodes().

◆ dig_isle_alloc_line()

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 466 of file struct_alloc.c.

Referenced by dig_Rd_P_isle().

◆ dig_node_alloc_line()

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.

Referenced by dig_Rd_P_node().

◆ dig_out_of_memory()

int dig_out_of_memory ( void  )

For now just print message and return error code.

Definition at line 487 of file struct_alloc.c.

References _, and G_warning().

Referenced by dig_alloc_cats(), and dig_alloc_points().