mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-10 01:21:25 +00:00
Improve excessive rapid root access performance
This commit is contained in:
38
jni/utils/list.c
Normal file
38
jni/utils/list.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/* list.h - Double link list implementation
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "list.h"
|
||||
|
||||
void init_list_head(struct list_head *head) {
|
||||
head->next = head;
|
||||
head->prev = head;
|
||||
}
|
||||
|
||||
void list_insert(struct list_head *pos, struct list_head *node) {
|
||||
// First construct our new node
|
||||
node->next = pos->next;
|
||||
node->prev = pos;
|
||||
// Maintain the list
|
||||
pos->next->prev = node;
|
||||
pos->next = node;
|
||||
}
|
||||
|
||||
void list_insert_end(struct list_head *head, struct list_head *node) {
|
||||
list_insert(head->prev, node);
|
||||
}
|
||||
|
||||
void list_pop(struct list_head *pos) {
|
||||
// Maintain the list
|
||||
pos->prev->next = pos->next;
|
||||
pos->next->prev = pos->prev;
|
||||
// Remove references
|
||||
pos->next = pos;
|
||||
pos->prev = pos;
|
||||
}
|
||||
|
||||
void list_pop_end(struct list_head *head) {
|
||||
return list_pop(head->prev);
|
||||
}
|
||||
Reference in New Issue
Block a user