#include <v_lib.h>

struct test
{
    int data;
	struct list_head link;
};

#define dump_list(ptr) \
	printf("List entry %X: prev is %X, next is %X\n", \
    (ptr),(ptr)->prev,(ptr)->next);

int main()
{
	int i;
	struct list_head head, *iterator;
    struct test s1, s2, s3;

	logStartConsoleLog();
	logUpperLevel(LOG_TRACE);
	
	INIT_LIST_HEAD(&head);

    list_add(&s1.link,&head);
    list_add(&s2.link,&head);
    list_add(&s3.link,&head);

    i=0;

    list_for_each(iterator,&head)
    {
    	struct test *ptr=list_entry(iterator,struct test,link);
        ptr->data = ++i;
	}
     
    /* list_del(&s1.link); */

    list_for_each(iterator,&head)
    {
    	struct test *ptr=list_entry(iterator,struct test,link);
		printf("ptr %X, data %X\n",ptr,ptr->data);
	}

	memPrintStats();
	return 0;
}

