mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-22 22:56:53 +03:00
f806f6b7f8
1) small heap 2) malloc 3) background image git-svn-id: svn://kolibrios.org@861 a494cfbc-eb01-0410-851d-a64ba20cac60
61 lines
1.2 KiB
C
61 lines
1.2 KiB
C
|
|
typedef struct link
|
|
{
|
|
struct link *prev;
|
|
struct link *next;
|
|
}link_t;
|
|
|
|
#define LIST_INITIALIZE(name) \
|
|
link_t name = { .prev = &name, .next = &name }
|
|
|
|
#define list_get_instance(link, type, member) \
|
|
((type *)(((u8_t *)(link)) - ((u8_t *)&(((type *)NULL)->member))))
|
|
|
|
static inline void link_initialize(link_t *link)
|
|
{
|
|
link->prev = NULL;
|
|
link->next = NULL;
|
|
}
|
|
|
|
static inline void list_initialize(link_t *head)
|
|
{
|
|
head->prev = head;
|
|
head->next = head;
|
|
}
|
|
|
|
static inline void list_append(link_t *link, link_t *head)
|
|
{
|
|
link->prev = head->prev;
|
|
link->next = head;
|
|
head->prev->next = link;
|
|
head->prev = link;
|
|
}
|
|
|
|
static inline void list_remove(link_t *link)
|
|
{
|
|
link->next->prev = link->prev;
|
|
link->prev->next = link->next;
|
|
link_initialize(link);
|
|
}
|
|
|
|
static inline bool list_empty(link_t *head)
|
|
{
|
|
return head->next == head ? true : false;
|
|
}
|
|
|
|
static inline void list_prepend(link_t *link, link_t *head)
|
|
{
|
|
link->next = head->next;
|
|
link->prev = head;
|
|
head->next->prev = link;
|
|
head->next = link;
|
|
}
|
|
|
|
static inline list_insert(link_t *new, link_t *old)
|
|
{
|
|
new->prev = old->prev;
|
|
new->next = old;
|
|
new->prev->next = new;
|
|
old->prev = new;
|
|
}
|