OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [gfx/] [mw/] [v2_0/] [src/] [engine/] [devlist.c] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#include <stdio.h>
2
#include <stdlib.h>
3
#include "device.h"
4
/*
5
 * linked list routines
6
 *
7
 * 1/28/98 g haerr
8
 * Copyright (c) 1999 Greg Haerr <greg@censoft.com>
9
 */
10
 
11
void *
12
GdItemAlloc(unsigned int size)
13
{
14
        return (void *)calloc(size, 1);
15
}
16
 
17
/* insert at tail of list*/
18
void
19
GdListAdd(PMWLISTHEAD pHead,PMWLIST pItem)
20
{
21
        if( pHead->tail) {
22
                pItem->prev = pHead->tail;
23
                pHead->tail->next = pItem;
24
        } else
25
                pItem->prev = NULL;
26
        pItem->next = NULL;
27
        pHead->tail = pItem;
28
        if( !pHead->head)
29
                pHead->head = pItem;
30
}
31
 
32
/* insert at head of list*/
33
void
34
GdListInsert(PMWLISTHEAD pHead,PMWLIST pItem)
35
{
36
        if( pHead->head) {
37
                pItem->next = pHead->head;
38
                pHead->head->prev = pItem;
39
        } else
40
                pItem->next = NULL;
41
        pItem->prev = NULL;
42
        pHead->head = pItem;
43
        if( !pHead->head)
44
                pHead->head = pItem;
45
}
46
 
47
void
48
GdListRemove(PMWLISTHEAD pHead,PMWLIST pItem)
49
{
50
        if( pItem->next)
51
                pItem->next->prev = pItem->prev;
52
        if( pItem->prev)
53
                pItem->prev->next = pItem->next;
54
        if( pHead->head == pItem)
55
                pHead->head = pItem->next;
56
        if( pHead->tail == pItem)
57
                pHead->tail = pItem->prev;
58
        pItem->next = pItem->prev = NULL;
59
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.