LingYun Studio embeded system framwork software, such as thirdparty build shell and lingyun library
guowenxue
2024-09-27 4e19749f95f47cb329d408559b458c4ba9f9653a
booster/testcase/list.c
@@ -32,6 +32,7 @@
    INIT_LIST_HEAD(&head);
    /* Create the link list */
    printf("Create link list:\n");
    for(i=0; i<10; i++)
    {
        node = malloc(sizeof(*node));
@@ -40,21 +41,21 @@
        printf("List add an node data : %p->%d\n", node, node->data);
        list_add_tail(&node->list, &head);
    }
    printf("\n");
    /* Use list_for_each_entry to travel list, we can not remove the node in it */
    printf("\nTraversing the list:\n");
    list_for_each_entry(node, &head, list)
    {
        printf("List travel node data : %p->%d\n", node, node->data);
    }
    printf("\n");
    /* Use list_for_each_entry_safe to destroy the list */
    printf("\nDestroy link list:\r\n");
    list_for_each_entry_safe(node, tmp, &head, list)
    {
        printf("List remove node data : %p->%d\n", node, node->data);
        list_del(&node->list);
      free(node);
        free(node);
    }
    printf("\n");