#include <stdio.h>
|
#include <stdio.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include "device.h"
|
#include "device.h"
|
/*
|
/*
|
* linked list routines
|
* linked list routines
|
*
|
*
|
* 1/28/98 g haerr
|
* 1/28/98 g haerr
|
* Copyright (c) 1999 Greg Haerr <greg@censoft.com>
|
* Copyright (c) 1999 Greg Haerr <greg@censoft.com>
|
*/
|
*/
|
|
|
void *
|
void *
|
GdItemAlloc(unsigned int size)
|
GdItemAlloc(unsigned int size)
|
{
|
{
|
return (void *)calloc(size, 1);
|
return (void *)calloc(size, 1);
|
}
|
}
|
|
|
/* insert at tail of list*/
|
/* insert at tail of list*/
|
void
|
void
|
GdListAdd(PMWLISTHEAD pHead,PMWLIST pItem)
|
GdListAdd(PMWLISTHEAD pHead,PMWLIST pItem)
|
{
|
{
|
if( pHead->tail) {
|
if( pHead->tail) {
|
pItem->prev = pHead->tail;
|
pItem->prev = pHead->tail;
|
pHead->tail->next = pItem;
|
pHead->tail->next = pItem;
|
} else
|
} else
|
pItem->prev = NULL;
|
pItem->prev = NULL;
|
pItem->next = NULL;
|
pItem->next = NULL;
|
pHead->tail = pItem;
|
pHead->tail = pItem;
|
if( !pHead->head)
|
if( !pHead->head)
|
pHead->head = pItem;
|
pHead->head = pItem;
|
}
|
}
|
|
|
/* insert at head of list*/
|
/* insert at head of list*/
|
void
|
void
|
GdListInsert(PMWLISTHEAD pHead,PMWLIST pItem)
|
GdListInsert(PMWLISTHEAD pHead,PMWLIST pItem)
|
{
|
{
|
if( pHead->head) {
|
if( pHead->head) {
|
pItem->next = pHead->head;
|
pItem->next = pHead->head;
|
pHead->head->prev = pItem;
|
pHead->head->prev = pItem;
|
} else
|
} else
|
pItem->next = NULL;
|
pItem->next = NULL;
|
pItem->prev = NULL;
|
pItem->prev = NULL;
|
pHead->head = pItem;
|
pHead->head = pItem;
|
if( !pHead->head)
|
if( !pHead->head)
|
pHead->head = pItem;
|
pHead->head = pItem;
|
}
|
}
|
|
|
void
|
void
|
GdListRemove(PMWLISTHEAD pHead,PMWLIST pItem)
|
GdListRemove(PMWLISTHEAD pHead,PMWLIST pItem)
|
{
|
{
|
if( pItem->next)
|
if( pItem->next)
|
pItem->next->prev = pItem->prev;
|
pItem->next->prev = pItem->prev;
|
if( pItem->prev)
|
if( pItem->prev)
|
pItem->prev->next = pItem->next;
|
pItem->prev->next = pItem->next;
|
if( pHead->head == pItem)
|
if( pHead->head == pItem)
|
pHead->head = pItem->next;
|
pHead->head = pItem->next;
|
if( pHead->tail == pItem)
|
if( pHead->tail == pItem)
|
pHead->tail = pItem->prev;
|
pHead->tail = pItem->prev;
|
pItem->next = pItem->prev = NULL;
|
pItem->next = pItem->prev = NULL;
|
}
|
}
|
|
|