Added and defined some functions
This commit is contained in:
parent
656658a0ef
commit
2cf9f97d2a
25
list/list.h
25
list/list.h
@ -22,11 +22,12 @@ int popFromTail(List *p_list);
|
||||
unsigned long int len(List *p_list);
|
||||
Node *findById(List *p_list, unsigned long int id);
|
||||
Node *findByValue(List *p_list, char type[], void *value);
|
||||
|
||||
int releaseList(List *p_list);
|
||||
int releaseNode(Node *p_node);
|
||||
|
||||
int insertInHead(List *p_list, Node *p_node){
|
||||
p_list->head->last = p_node;
|
||||
//p_node->last = NULL;
|
||||
p_node->last = NULL;
|
||||
p_node->next = p_list->head;
|
||||
p_list->head = p_node;
|
||||
return 0;
|
||||
@ -34,8 +35,26 @@ int insertInHead(List *p_list, Node *p_node){
|
||||
|
||||
int insertInTail(List *p_list, Node *p_node){
|
||||
p_list->tail->next = p_node;
|
||||
//p_node->next = NULL;
|
||||
p_node->next = NULL;
|
||||
p_node->last = p_list->tail;
|
||||
p_list->tail = p_node;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int releaseNode(Node *p_node){
|
||||
free(p_node->value);
|
||||
free(p_node);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int releaseList(List *p_list){
|
||||
Node *p_node, *pl_node;
|
||||
p_node = p_list->head;
|
||||
while (p_node != NULL){
|
||||
pl_node = p_node;
|
||||
p_node = p_node->next;
|
||||
releaseNode(pl_node);
|
||||
}
|
||||
free(p_list);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user