inserts a feature at the end of the list, can create a new list */
| 759 | |
| 760 | /* inserts a feature at the end of the list, can create a new list */ |
| 761 | featureListNodeObjPtr insertFeatureList(featureListNodeObjPtr *list, shapeObj *shape) |
| 762 | { |
| 763 | featureListNodeObjPtr node; |
| 764 | |
| 765 | node = (featureListNodeObjPtr) malloc(sizeof(featureListNodeObj)); |
| 766 | MS_CHECK_ALLOC(node, sizeof(featureListNodeObj), NULL); |
| 767 | |
| 768 | msInitShape(&(node->shape)); |
| 769 | if(msCopyShape(shape, &(node->shape)) == -1) return(NULL); |
| 770 | |
| 771 | /* AJS - alans@wunderground.com O(n^2) -> O(n) conversion, keep a pointer to the end */ |
| 772 | |
| 773 | /* set the tailifhead to NULL, since it is only set for the head of the list */ |
| 774 | node->tailifhead = NULL; |
| 775 | node->next = NULL; |
| 776 | |
| 777 | /* if we are at the head of the list, we need to set the list to node, before pointing tailifhead somewhere */ |
| 778 | if(*list == NULL) { |
| 779 | *list=node; |
| 780 | } else { |
| 781 | if((*list)->tailifhead!=NULL) /* this should never be NULL, but just in case */ |
| 782 | (*list)->tailifhead->next=node; /* put the node at the end of the list */ |
| 783 | } |
| 784 | |
| 785 | /* repoint the head of the list to the end - our new element |
| 786 | this causes a loop if we are at the head, be careful not to |
| 787 | walk in a loop */ |
| 788 | (*list)->tailifhead = node; |
| 789 | |
| 790 | return(node); /* a pointer to last object in the list */ |
| 791 | } |
| 792 | |
| 793 | void freeFeatureList(featureListNodeObjPtr list) |
| 794 | { |
no test coverage detected