Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
123ae985
Commit
123ae985
authored
Jul 30, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/list: make safe for C++
parent
659d1c7c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
24 deletions
+25
-24
list.h
src/util/list.h
+25
-24
No files found.
src/util/list.h
View file @
123ae985
...
...
@@ -47,8 +47,8 @@
* under normal circumstances, used to verify that nobody uses
* non-initialized list entries.
*/
#define LIST_POISON1 ((void *) 0x00100100)
#define LIST_POISON2 ((void *) 0x00200200)
#define LIST_POISON1 ((
struct list_head *)(
void *) 0x00100100)
#define LIST_POISON2 ((
struct list_head *)(
void *) 0x00200200)
/*
* Simple doubly linked list implementation.
...
...
@@ -82,46 +82,47 @@ static inline void INIT_LIST_HEAD(struct list_head *list)
* the prev/next entries already!
*/
#ifndef CONFIG_DEBUG_LIST
static
inline
void
__list_add
(
struct
list_head
*
new
,
static
inline
void
__list_add
(
struct
list_head
*
new
_item
,
struct
list_head
*
prev
,
struct
list_head
*
next
)
{
next
->
prev
=
new
;
new
->
next
=
next
;
new
->
prev
=
prev
;
prev
->
next
=
new
;
next
->
prev
=
new
_item
;
new
_item
->
next
=
next
;
new
_item
->
prev
=
prev
;
prev
->
next
=
new
_item
;
}
#else
extern
void
__list_add
(
struct
list_head
*
new
,
struct
list_head
*
prev
,
struct
list_head
*
next
);
extern
void
__list_add
(
struct
list_head
*
new
_item
,
struct
list_head
*
prev
,
struct
list_head
*
next
);
#endif
/**
* list_add - add a new entry
* @new: new entry to be added
* @new
_item
: new entry to be added
* @head: list head to add it after
*
* Insert a new entry after the specified head.
* This is good for implementing stacks.
*/
static
inline
void
list_add
(
struct
list_head
*
new
,
struct
list_head
*
head
)
static
inline
void
list_add
(
struct
list_head
*
new
_item
,
struct
list_head
*
head
)
{
__list_add
(
new
,
head
,
head
->
next
);
__list_add
(
new
_item
,
head
,
head
->
next
);
}
/**
* list_add_tail - add a new entry
* @new: new entry to be added
* @new
_item
: new entry to be added
* @head: list head to add it before
*
* Insert a new entry before the specified head.
* This is useful for implementing queues.
*/
static
inline
void
list_add_tail
(
struct
list_head
*
new
,
struct
list_head
*
head
)
static
inline
void
list_add_tail
(
struct
list_head
*
new_item
,
struct
list_head
*
head
)
{
__list_add
(
new
,
head
->
prev
,
head
);
__list_add
(
new
_item
,
head
->
prev
,
head
);
}
/*
...
...
@@ -163,23 +164,23 @@ extern void list_del(struct list_head *entry);
/**
* list_replace - replace old entry by new one
* @old : the element to be replaced
* @new : the new element to insert
* @new
_item
: the new element to insert
*
* If @old was empty, it will be overwritten.
*/
static
inline
void
list_replace
(
struct
list_head
*
old
,
struct
list_head
*
new
)
struct
list_head
*
new
_item
)
{
new
->
next
=
old
->
next
;
new
->
next
->
prev
=
new
;
new
->
prev
=
old
->
prev
;
new
->
prev
->
next
=
new
;
new
_item
->
next
=
old
->
next
;
new
_item
->
next
->
prev
=
new_item
;
new
_item
->
prev
=
old
->
prev
;
new
_item
->
prev
->
next
=
new_item
;
}
static
inline
void
list_replace_init
(
struct
list_head
*
old
,
struct
list_head
*
new
)
struct
list_head
*
new_item
)
{
list_replace
(
old
,
new
);
list_replace
(
old
,
new
_item
);
INIT_LIST_HEAD
(
old
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment