home *** CD-ROM | disk | FTP | other *** search
- /* list.c */
-
- #include <stdlib.h>
- #include "chunks.h"
-
- void xFiles_InitItem(xFiles_listItem *pItem)
- {
- pItem->prev =
- pItem->next = NULL;
- }
-
- void xFiles_InitList(xFiles_list *pList)
- {
- pList->head =
- pList->tail = NULL;
- }
-
- void xFiles_AddAtHead(xFiles_list *pList, xFiles_listItem *pItem)
- {
- pItem->prev = NULL;
- pItem->next = pList->head;
-
- if (pList->tail)
- pList->head->prev = pItem;
- else
- pList->tail = pItem;
-
- pList->head = pItem;
- }
-
- void xFiles_AddAtTail(xFiles_list *pList, xFiles_listItem *pItem)
- {
- pItem->prev = pList->tail;
- pItem->next = NULL;
-
- if (pList->head)
- pList->tail->next = pItem;
- else
- pList->head = pItem;
-
- pList->tail = pItem;
- }
-
- void xFiles_Remove(xFiles_list *pList, xFiles_listItem *pItem)
- {
- if (pItem->prev)
- pItem->prev->next = pItem->next;
- else
- pList->head = pItem->next;
-
- if (pItem->next)
- pItem->next->prev = pItem->prev;
- else
- pList->tail = pItem->prev;
- }
-