10#ifndef __TUYA_LIST_H__
11#define __TUYA_LIST_H__
13#include "tuya_cloud_types.h"
33#define LIST_HEAD_INIT(name) { &(name), &(name) }
34#define LIST_HEAD(name) \
35LIST_HEAD name = LIST_HEAD_INIT(name)
41#define INIT_LIST_HEAD(ptr) do { \
42(ptr)->next = (ptr); (ptr)->prev = (ptr); \
49#define NEW_LIST_NODE(type, node) \
51 node = (type *)tal_malloc(sizeof(type));\
58#define FREE_LIST(type, p, list_name)\
61 while(!tuya_list_empty(&(p)->list_name)) {\
62 posnode = tuya_list_entry((&(p)->list_name)->next, type, list_name);\
63 tuya_list_del((&(p)->list_name)->next);\
72#define GetFirstNode(type,p,list_name,pGetNode)\
75 while(!tuya_list_empty(&(p)->list_name)){\
76 pGetNode = tuya_list_entry((&(p)->list_name)->next, type, list_name);\
86#define DeleteNodeAndFree(pDelNode,list_name)\
88 tuya_list_del(&(pDelNode->list_name));\
96#define DeleteNode(pDelNode,list_name)\
98 tuya_list_del(&(pDelNode->list_name));\
105#define FreeNode(pDelNode)\
114#define tuya_list_entry(ptr, type, member) \
115((type *)((char *)(ptr)-(size_t)(&((type *)0)->member)))
121#define tuya_list_for_each(pos, head) \
122for (pos = (head)->next; (pos != NULL) && (pos != (head)); pos = pos->next)
128#define tuya_list_for_each_safe(p, n, head) \
129for (p = (head)->next; n = p->next, p != (head); p = n)
bidirection list head
Definition: tuya_list.h:25
INT_T tuya_list_empty(const P_LIST_HEAD pHead)
check if the bidirection list is empty
struct tuya_list_head LIST_HEAD
bidirection list head
void tuya_list_del(const P_LIST_HEAD pEntry)
remove a list node from bidirection list
void tuya_list_add_tail(const P_LIST_HEAD pNew, const P_LIST_HEAD pHead)
add new list node to the tail of the bidirection list
void tuya_list_splice(const P_LIST_HEAD pList, const P_LIST_HEAD pHead)
splice two dibrection list
void tuya_list_add(const P_LIST_HEAD pNew, const P_LIST_HEAD pHead)
add new list node into bidirection list
void tuya_list_del_init(const P_LIST_HEAD pEntry)
remove a list node from bidirection list and initialize it