forked from ghaerr/microwindows
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevlist.c
More file actions
58 lines (54 loc) · 1.06 KB
/
Copy pathdevlist.c
File metadata and controls
58 lines (54 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdlib.h>
#include "device.h"
/*
* linked list routines
*
* 1/28/98 g haerr
* Copyright (c) 1999 Greg Haerr <greg@censoft.com>
*/
void *
GdItemAlloc(unsigned int size)
{
return (void *)calloc(size, 1);
}
/* insert at tail of list*/
void
GdListAdd(PMWLISTHEAD pHead,PMWLIST pItem)
{
if( pHead->tail) {
pItem->prev = pHead->tail;
pHead->tail->next = pItem;
} else
pItem->prev = NULL;
pItem->next = NULL;
pHead->tail = pItem;
if( !pHead->head)
pHead->head = pItem;
}
/* insert at head of list*/
void
GdListInsert(PMWLISTHEAD pHead,PMWLIST pItem)
{
if( pHead->head) {
pItem->next = pHead->head;
pHead->head->prev = pItem;
} else
pItem->next = NULL;
pItem->prev = NULL;
pHead->head = pItem;
if( !pHead->head)
pHead->head = pItem;
}
void
GdListRemove(PMWLISTHEAD pHead,PMWLIST pItem)
{
if( pItem->next)
pItem->next->prev = pItem->prev;
if( pItem->prev)
pItem->prev->next = pItem->next;
if( pHead->head == pItem)
pHead->head = pItem->next;
if( pHead->tail == pItem)
pHead->tail = pItem->prev;
pItem->next = pItem->prev = NULL;
}