insert2Ha.c 1.3 KB

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