1
2 /***************************************************************/
3 /* */
4 /* insert2Ha.c in ~/rsc.src/spread */
5 /* */
6 /* This routine creates a queue (linked list) of cell_ptr */
7 /* data structures. It allocates memory for the cell to */
8 /* be inserted, assigns given coordinates to the structure */
9 /* attributes, then it insert the new cell into the list. */
10 /* */
11
12 /***************************************************************/
13
14 #include <grass/gis.h>
15 #include "cell_ptrHa.h"
16 #include "local_proto.h"
17
18 void
insert2Ha(struct cell_ptrHa ** front_cell,struct cell_ptrHa ** rear_cell,float angle,int row,int col)19 insert2Ha(struct cell_ptrHa **front_cell,
20 struct cell_ptrHa **rear_cell, float angle, int row, int col)
21 {
22 struct cell_ptrHa *temp_cell, *temp_cell2;
23
24 temp_cell = (struct cell_ptrHa *)(G_malloc(sizeof(struct cell_ptrHa)));
25
26 temp_cell->angle = angle;
27 temp_cell->row = row;
28 temp_cell->col = col;
29
30 if (*front_cell == NULL) {
31 *front_cell = temp_cell;
32 *rear_cell = temp_cell;
33 temp_cell->next = NULL;
34 }
35 else {
36 temp_cell2 = *rear_cell;
37 temp_cell2->next = temp_cell;
38 *rear_cell = temp_cell;
39 temp_cell->next = NULL;
40 }
41 return;
42 }
43
44 /**************** END OF FUNCTION "INSERT2HA" *********************/
45