#define hlist_for_each_safe(pos, n, head) \ for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \ pos = n) //通用的哈希链表遍历,当中 pos指向当前节点。 tpos指向的包括hlist_node的当前结构体的指针 #define hlist_for_each_entry(tpos, pos, head, member) \ for (...
在上述示例中,hlist_for_each_entry()宏用于遍历哈希表中的链表中的结构体。通过结合hlist_entry_safe()宏,我们可以在每次迭代中获取结构体指针,并对结构体中的成员执行操作。 使用hlist_for_each_entry()宏可以方便地遍历哈希表中的链表,并对链表中的结构体执行操作,例如查找、修改或删除等操作。 (2-17)hlist...
//遍历结点过程中有删除结点操作使用这个接口 hlist_for_each_safe(pos, n, head) 1. 2. 3. 4. 5. //遍历获取结点里的数据 hlist_for_each_entry(tpos, pos, head, member) 1. 2. //遍历结点过程中有删除结点操作使用这个接口 1. hlist_for_each_entry_safe(tpos, pos, n, head, member) 1. ...
#definehlist_entry(ptr, type, member) container_of(ptr,type,member) //用pos作为游标来遍历这个链表,prefetch是数据预取 #definehlist_for_each(pos, head) \ for(pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \ pos = pos->next) #definehlist_for_each_safe(pos, n, hea...
hlist_for_each_entry_safe遍历过程中删除了节点,可安全遍历后面的节点 /*** hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry* @pos: the type * to use as a loop cursor.* @n: a &struct hlist_node to use as temporary storage* @head: the ...
再强调一下,当我们要利用内核的哈希表实现自己的代码的时候,用到这两个宏来遍历我们的哈希链表的时候,记得:如果要遍历之后有删除的操作,一定要用safe版本。 11、以下这三个宏完成一样的功能:遍历哈希链表,并且获得其所在结构体的指针tpos。hlist_for_each_entry版本从表头开始遍历,而hlist_for_each_entry_continue...
void free_hash_table(void) { int i; struct my_data *data; struct hlist_node *tmp; for (i = 0; i< hash_table_size; i++) { hlist_for_each_entry_safe(data, tmp, &my_hash_table[i], node) { hlist_del(&data->node); kfree(data); } } kfree(my_hash_table); } 复制代码...
3.9. list_for_each_entry_safe 3.9.1. 定义 // pos:指向当前结点(在这里,类型为MyNode)的指针 // head:指向双向链表list_head的头的指针 // member:list_head类型在MyNode中的成员(在这里为list) // n:用来临时存储pos的下一个结点(类型和pos相同) ...
51CTO博客已为您找到关于hlist_for_each_entry的相关内容,包含IT学习相关文档代码介绍、相关教程视频课程,以及hlist_for_each_entry问答内容。更多hlist_for_each_entry相关解答可以来51CTO博客参与分享和学习,帮助广大IT技术人实现成长和进步。
问hlist_for_each_entry_rcu是否需要额外的指针才能传递给它?EN执行结果中并未输出字符串hello其实这里...