+struct active_list * active_list_prev(struct active_list *head, struct active_list *ptr) {
+ struct active_list *prev=NULL;
+ if ( !head ) {
+ fprintf(stderr, "active_list_prev head = %p, ptr = %p invalid value!!\n", head, ptr);
+ return NULL;
+ }
+ if ( !ptr )
+ ptr = head;
+ if ( ptr->depend.prev != &ptr->depend ) {
+ prev = list_entry(ptr->depend.prev, struct active_list, node);
+ return prev;
+ }
+ if ( ptr->depended && ptr->depended != head && &ptr->depended->depend == ptr->node.prev ) {
+ prev = list_entry(ptr->depended->node.prev, struct active_list, node);
+ } else
+ prev = list_entry(ptr->node.prev, struct active_list, node);
+ if ( prev == head )
+ return NULL;
+ return prev;
+}
+
+
+struct active_list *active_list_move_node(struct active_list *old_head, struct active_list *new_head, struct active_list *node) {
+ struct active_list *prev;
+ if (!old_head || !new_head || !node)
+ return NULL;
+ if (old_head == new_head)
+ return node;
+ prev = active_list_prev(old_head, node);
+ active_list_add(new_head, node);
+ return prev;
+}
+
+static void list_head_clear (struct list_head *head) {
+ struct active_list *next;
+ struct list_head *n, *ptr;
+ if (!head)
+ return;
+ list_for_each_safe(ptr, n , head) {
+ next = list_entry(ptr, struct active_list, node);
+ if (next->depend.next != &next->depend) {
+ list_head_clear(&next->depend);
+ }
+ active_list_init(next);
+ }
+}