📄 listed_link.c
字号:
#include "spiht.h"
#include "spihtdecode.h"
void QccListInitialize(QccList *list)
{
list->start = NULL;
list->end = NULL;
}
void QccListFreeNode(QccListNode *node)
{
if (node == NULL)
return;
if (node->value != NULL)
{
free(node->value);
node->value = NULL;
}
free(node);
}
void QccListFree(QccList *list)
{
QccListNode *current;
QccListNode *next;
if (list == NULL)
return;
current = list->start;
while (current != NULL)
{
next = current->next;
QccListFreeNode(current);
current = next;
}
list->start = NULL;
list->end = NULL;
}
QccListNode *QccListCreateNode(int value_size, const void *value)
{
QccListNode *new_node = NULL;
if ((new_node = (QccListNode *)malloc(sizeof(QccListNode))) == NULL)
{
QccErrorAddMessage("(QccListCreateNode): Error allocating memory");
return(NULL);
}
new_node->previous = NULL;
new_node->next = NULL;
new_node->value_size = value_size;
if ((new_node->value = (void *)malloc(value_size)) == NULL)
{
QccErrorAddMessage("(QccListCreateNode): Error allocating memory");
return(NULL);
}
if (value != NULL)
memcpy(new_node->value, value, value_size);
return(new_node);
}
int QccListAppendNode(QccList *list, QccListNode *node)
{
if (list == NULL)
return(0);
if (node == NULL)
return(0);
if (list->start == NULL)
{
node->previous = NULL;
node->next = NULL;
list->start = node;
list->end = node;
return(0);
}
node->previous = list->end;
node->next = NULL;
(list->end)->next = node;
list->end = node;
return(0);
}
int QccListRemoveNode(QccList *list, QccListNode *node)
{
if (list == NULL)
return(0);
if (node == NULL)
return(0);
if (node->previous == NULL)
{
list->start = node->next;
if (list->start != NULL)
(list->start)->previous = NULL;
}
else
(node->previous)->next = node->next;
if (node->next == NULL)
list->end = node->previous;
else
(node->next)->previous = node->previous;
return(0);
}
int QccListDeleteNode(QccList *list, QccListNode *node)
{
if (QccListRemoveNode(list, node))
{
QccErrorAddMessage("QccListDeleteNode): Error calling QccListRemoveNode()");
return(1);
}
QccListFreeNode(node);
return(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -