You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
eon/linked_list/linked_list.c

44 lines
795 B

5 years ago
#include <stdlib.h>
#include "linked_list.h"
/**
* free's a linked list
* @param head of linked list to be freed
* @return void
*/
void _free_linked_list(node_info *pList) {
node_info *temp;
while(pList->next != NULL) {
temp = pList;
pList = pList->next;
free(temp);
}
}
/**
* returns a copy of list
* @param nodeInfo list to be copied
* @return copied list
*/
node_info *copy_linked_list(node_info *pList) {
node_info *newList = malloc(sizeof(node_info));
newList->next = NULL;
node_info *copy_list = newList;
while(pList->next != NULL) {
pList = pList->next;
copy_list->next = pList;
copy_list = copy_list->next;
}
return newList;
}