Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
9d421226
Commit
9d421226
authored
Jul 02, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update list implementation
parent
7b9be836
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
14 deletions
+31
-14
su
jni/su
+1
-1
list.c
jni/utils/list.c
+6
-2
list.h
jni/utils/list.h
+24
-11
No files found.
su
@
9dab3bc8
Subproject commit
1bbf96a0a7a942798df58883a376b8024d0fae7f
Subproject commit
9dab3bc8ab28792993711f0a2450f9332b172687
jni/utils/list.c
View file @
9d421226
...
@@ -24,15 +24,19 @@ void list_insert_end(struct list_head *head, struct list_head *node) {
...
@@ -24,15 +24,19 @@ void list_insert_end(struct list_head *head, struct list_head *node) {
list_insert
(
head
->
prev
,
node
);
list_insert
(
head
->
prev
,
node
);
}
}
void
list_pop
(
struct
list_head
*
pos
)
{
struct
list_head
*
list_pop
(
struct
list_head
*
pos
)
{
struct
list_head
*
ret
;
ret
=
pos
->
prev
;
// Maintain the list
// Maintain the list
pos
->
prev
->
next
=
pos
->
next
;
pos
->
prev
->
next
=
pos
->
next
;
pos
->
next
->
prev
=
pos
->
prev
;
pos
->
next
->
prev
=
pos
->
prev
;
// Remove references
// Remove references
pos
->
next
=
pos
;
pos
->
next
=
pos
;
pos
->
prev
=
pos
;
pos
->
prev
=
pos
;
// Return the previous node in the list
return
ret
;
}
}
void
list_pop_end
(
struct
list_head
*
head
)
{
struct
list_head
*
list_pop_end
(
struct
list_head
*
head
)
{
return
list_pop
(
head
->
prev
);
return
list_pop
(
head
->
prev
);
}
}
jni/utils/list.h
View file @
9d421226
...
@@ -14,17 +14,30 @@ struct list_head {
...
@@ -14,17 +14,30 @@ struct list_head {
void
init_list_head
(
struct
list_head
*
head
);
void
init_list_head
(
struct
list_head
*
head
);
void
list_insert
(
struct
list_head
*
pos
,
struct
list_head
*
node
);
void
list_insert
(
struct
list_head
*
pos
,
struct
list_head
*
node
);
void
list_insert_end
(
struct
list_head
*
head
,
struct
list_head
*
node
);
void
list_insert_end
(
struct
list_head
*
head
,
struct
list_head
*
node
);
void
list_pop
(
struct
list_head
*
pos
);
struct
list_head
*
list_pop
(
struct
list_head
*
pos
);
void
list_pop_end
(
struct
list_head
*
head
);
struct
list_head
*
list_pop_end
(
struct
list_head
*
head
);
#define list_entry(p
tr
, type, member) ({ \
#define list_entry(p
os
, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (p
tr
); \
const typeof( ((type *)0)->member ) *__mptr = (p
os
); \
(type *)( (char *)__mptr - offsetof(type,member) );})
(type *)( (char *)__mptr - offsetof(type,member) );})
#define list_for_each(pos, head) \
#define list_for_each(ptr, head, type, member) \
for (pos = (head)->next; pos != (head); pos = pos->next)
ptr = list_entry((head)->next, type, member); \
for (struct list_head *__ = (head)->next; __ != (head); __ = __->next, ptr = list_entry(__, type, member))
#define list_for_each_r(pos, head) \
for (pos = (head)->prev; pos != (head); pos = pos->prev)
#define list_for_each_r(ptr, head, type, member) \
ptr = list_entry((head)->prev, type, member); \
#endif
for (struct list_head *__ = (head)->prev; __ != (head); __ = __->prev, ptr = list_entry(__, type, member))
\ No newline at end of file
#define list_destory(head, type, member, func) ({ \
struct list_head *node = head->next; \
while(node != head) { \
node = node->next; \
if (func) func(list_entry(node->prev, line_list, pos)); \
free(list_entry(node->prev, line_list, pos)); \
} \
head->next = head; \
head->prev = head; \
})
#endif
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