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.
33 lines
742 B
33 lines
742 B
#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 *p_list) {
|
|
node_info *temp;
|
|
while(p_list->next != NULL) {
|
|
temp = p_list;
|
|
p_list = p_list->next;
|
|
free(temp);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* returns a copy of list
|
|
* @param nodeInfo list to be copied
|
|
* @return copied list
|
|
*/
|
|
node_info *copy_linked_list(node_info *p_list) {
|
|
node_info *new_list = malloc(sizeof(node_info));
|
|
new_list->next = NULL;
|
|
node_info *copy_list = new_list;
|
|
while(p_list->next != NULL) {
|
|
p_list = p_list->next;
|
|
copy_list->next = p_list;
|
|
copy_list = copy_list->next;
|
|
}
|
|
return new_list;
|
|
} |