37 lines
487 B
C
37 lines
487 B
C
|
/*
|
||
|
* list.c
|
||
|
*
|
||
|
* Created on: Jul 27, 2016
|
||
|
* Author: tkl
|
||
|
*/
|
||
|
|
||
|
#include "stddef.h"
|
||
|
#include "list.h"
|
||
|
|
||
|
int list_init(struct list *head)
|
||
|
{
|
||
|
if(NULL == head)
|
||
|
return -1;
|
||
|
|
||
|
head->front = NULL;
|
||
|
head->rear = NULL;
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int list_add(struct list *head, struct list_node *node)
|
||
|
{
|
||
|
if((NULL == head) || (NULL == node))
|
||
|
return -1;
|
||
|
|
||
|
if(head->front == NULL) {
|
||
|
head->front = node;
|
||
|
head->rear = node;
|
||
|
}
|
||
|
else {
|
||
|
head->rear->next = node;
|
||
|
head->rear = node;
|
||
|
}
|
||
|
return 1;
|
||
|
}
|