int main(int argc, char *argv[]) { struct list list; list.head = list.tail = NULL; list_add(&list, 1337); list_add(&list, 666); list_add(&list, 69); list_del(&list); for (struct node *n = list.head; n != NULL; n = n->next) { printf("%d\n", n->cfd); if (n->cfd == 69) list_del_node(&list, n); } for (struct node *n = list.head; n != NULL; n = n->next) { printf("%d\n", n->cfd); list_del_node(&list, n); } for (struct node *n = list.head; n != NULL; n = n->next) printf("%d\n", n->cfd); list_add(&list, 1); list_add(&list, 2); list_add(&list, 3); list_add(&list, 4); list_add(&list, 5); for (struct node *n = list.head; n != NULL; n = n->next) printf("%d\n", n->cfd); return 0; }
/* * Block id, removed from the list and return to the block pointer */ static list_head_t *List_Delete_Sprite_Block(__u32 sel, list_head_t *node) { __s32 id = 0; if (node != NULL) { id = node->data->id; if (id == 0) { /* delete the first block */ __s32 next_id = 0; list_head_t *next_node = NULL; next_id = node->next->data->id; next_node = node->next; if (id == next_id) /* free the only block */ gsprite[sel].header = NULL; else { __s32 id_tmp = 0; id_tmp = gsprite[sel].sprite_hid[0]; gsprite[sel].sprite_hid[0] = gsprite[sel].sprite_hid[next_id]; gsprite[sel].sprite_hid[next_id] = id_tmp; next_node->data->id = 0; node->data->id = next_id; gsprite[sel].header = next_node; } } list_del_node(node); return node; } else return NULL; }
t_bool map_del_elem(t_map *map_ptr, void *key, t_key_comparator key_cmp) { t_map head; head = *map_ptr; while (head != NULL && key_cmp(((t_pair *)(head->value))->key, key)) head = head->next; return (list_del_node(map_ptr, head)); }
void wakeup_queue(struct list_node *queue) { struct list_node *ctr; /* move each element on the wait queue to the run queue */ /* FIXME: this can probably be optimized */ while((ctr = queue->next) != queue) { list_del_node(ctr); list_append_node(&run_list, ctr); } schedule(); }
void ll_ns_free(void) { struct ll_namespace *i, *tmp; list_foreach_safe(&namespaces, i, tmp, struct ll_namespace, list) { list_del_node(&i->list); if (i->close_cb) { i->close_cb(i->priv); } free(i); } }
static struct sock_buff *sock_recv_packet(struct socket *sock) { __UNUSED__ __u32 psr; struct sock_buff *skb; struct list_node *first; int to = 10000; // timeout int ret; char key; while (1) { ret = uart_read(CONFIG_UART_INDEX, (__u8 *)&key, 1, WAIT_ASYNC); if (ret > 0 && key == CHAR_CTRL_C) return NULL; ndev_poll(); lock_irq_psr(psr); if (!list_is_empty(&sock->rx_qu)) { unlock_irq_psr(psr); break; } unlock_irq_psr(psr); if (sock->obstruct_flags == 1) { to--; if (to == 0) break; } udelay(1000); } if (to > 0) { lock_irq_psr(psr); first = sock->rx_qu.next; list_del_node(first); unlock_irq_psr(psr); skb = container_of(first, struct sock_buff, node); return skb; }