昆明网站建设工作室夜晚必备直播软件

diannao/2026/1/26 14:24:03/文章来源:
昆明网站建设工作室,夜晚必备直播软件,设计工作室与网站建设工作室,微信app下载安装旧版本以前都是自己写链表或者所用框架都自带链表操作#xff0c;本次工作换了框架没有找到框架自带的链表操作#xff0c;所以尝试使用linux自带的list.h中定义的相关宏和函数写了简单的链表操作#xff0c;竟然踩坑了#xff0c;记录一下。 一、list.h简介 list.h一般放在inc… 以前都是自己写链表或者所用框架都自带链表操作本次工作换了框架没有找到框架自带的链表操作所以尝试使用linux自带的list.h中定义的相关宏和函数写了简单的链表操作竟然踩坑了记录一下。 一、list.h简介 list.h一般放在include/list.h当然有的linux系统放list.h地方在别的地方比如ubuntu。可以使用find / -name list.h找到使用gcc编译的时候include上。 list.h是Linux内核中为了提供统一的链表操作减少结构体的额外开支提供的链表操作。list.h中定义的链表了一个双向循环链表和一个哈希表。 1基本结构 struct list_head {struct list_head *next, *prev; };2初始化定义 #define LIST_HEAD_INIT(name) { (name), (name) }#define LIST_HEAD(name) \struct list_head name LIST_HEAD_INIT(name)3功能定义 /**添加节点* list_add_tail - add a new entry* new: new entry to be added* head: list head to add it before* * Insert a new entry before the specified head.* This is useful for implementing queues.*/ static inline void list_add_tail(struct list_head *_new, struct list_head *head) {__list_add(_new, head-prev, head); }/**删除节点* list_del - deletes entry from list.* entry: the element to delete from the list.* Note: list_empty() on entry does not return true after this, the entry is* in an undefined state.*/ static inline void list_del(struct list_head *entry) {__list_del(entry-prev, entry-next);entry-next (struct list_head*)LIST_POISON1;entry-prev (struct list_head*)LIST_POISON2; }/**链表判断* list_empty - tests whether a list is empty* head: the list to test.*/ static inline int list_empty(const struct list_head *head) {return head-next head; }4查询定义 /** 直接读取节点的查询方法1* list_for_each_entry - iterate over list of given type* pos: the type * to use as a loop cursor.* head: the head for your list.* member: the name of the list_head within the struct.*/ #define list_for_each_entry(pos, head, member) \for (pos list_entry((head)-next, typeof(*pos), member); \pos-member ! (head); \pos list_entry(pos-member.next, typeof(*pos), member))/**直接读取节点的查询方法2* list_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: another type * to use as temporary storage* head: the head for your list.* member: the name of the list_head within the struct.*/ #define list_for_each_entry_safe(pos, n, head, member) \for (pos list_entry((head)-next, typeof(*pos), member), \n list_entry(pos-member.next, typeof(*pos), member); \pos-member ! (head); \pos n, n list_entry(n-member.next, typeof(*n), member)) 二、实战 程序大概的意思是创建一个5个成员的stu链表打印删除其中一个成员再打印。带参数的可执行程序./test 1标识删除第一个后面数字表示删除第几个。 #include list.h #include stdlib.h #include stdio.htypedef struct _ststudent_ {int age;int grade; }STU_T;typedef struct _stulist_ {STU_T stStu;struct list_head list; }STU_LIST_T;LIST_HEAD(g_stStuList_Head); void main(int argc,char *argv[]) {STU_LIST_T *pstStuNULL;STU_LIST_T *pstStu_outNULL;STU_LIST_T *nNULL;int i0;for(i0;i5;i){pstStu(STU_LIST_T*)malloc(sizeof(STU_LIST_T));pstStu-stStu.agei10;pstStu-stStu.gradei100;list_add_tail(pstStu-list,g_stStuList_Head);}printf(----------------add---------------------\n);list_for_each_entry(pstStu_out,g_stStuList_Head,list){printf(pstStu_out-stStu.age%d,grade%d\n,pstStu_out-stStu.age,pstStu_out-stStu.grade);}printf(----------------del---------------------\n);#ifdef TEST_TRUElist_for_each_entry(pstStu_out,g_stStuList_Head,list){if(atoi(argv[1])pstStu_out-stStu.age-10){list_del(pstStu_out-list);free(pstStu_out);continue;}printf(pstStu_out-stStu.age%d,grade%d\n,pstStu_out-stStu.age,pstStu_out-stStu.grade);}#elselist_for_each_entry_safe(pstStu_out,n,g_stStuList_Head,list){if(atoi(argv[1])pstStu_out-stStu.age-10){list_del(pstStu_out-list);free(pstStu_out);continue;}printf(pstStu_out-stStu.age%d,grade%d\n,pstStu_out-stStu.age,pstStu_out-stStu.grade);} #endifreturn; } 1为啥不用#include list.h 因为我自己系统带的list.h不在标准库。。 rootubuntu:/home/Ctest/clistTest# find / -name list.h /lib/firmware/carl9170fw/tools/include/list.h find: ‘/run/user/1000/gvfs’: Permission denied /usr/src/linux-hwe-5.4-headers-5.4.0-150/scripts/kconfig/list.h /usr/src/linux-hwe-5.4-headers-5.4.0-150/include/linux/list.h /usr/src/linux-headers-5.4.0-150-generic/scripts/kconfig/list.h /usr/src/linux-headers-5.4.0-150-generic/include/config/system/blacklist/hash/list.h /usr/src/linux-headers-5.4.0-150-generic/include/config/system/revocation/list.h /usr/src/linux-hwe-5.4-headers-5.4.0-136/scripts/kconfig/list.h /usr/src/linux-hwe-5.4-headers-5.4.0-136/include/linux/list.h /usr/src/linux-hwe-5.4-headers-5.4.0-135/scripts/kconfig/list.h /usr/src/linux-hwe-5.4-headers-5.4.0-135/include/linux/list.h /usr/src/linux-headers-5.4.0-135-generic/scripts/kconfig/list.h /usr/src/linux-headers-5.4.0-135-generic/include/config/system/blacklist/hash/list.h /usr/src/linux-headers-5.4.0-135-generic/include/config/system/revocation/list.h /usr/src/linux-headers-5.4.0-136-generic/scripts/kconfig/list.h /usr/src/linux-headers-5.4.0-136-generic/include/config/system/blacklist/hash/list.h /usr/src/linux-headers-5.4.0-136-generic/include/config/system/revocation/list.h 2编译 gcc -o test listtest.c -I /usr/src/linux-hwe-5.4-headers-5.4.0-150/scripts/kconfig/ -DTEST_TRUE 3-D是为了方便测试 预编译宏。 用来分别编译两个可执行程序说明遇到的坑 4运行结果带参数运行 坑如果只查询使用list_for_each_entry()和list_for_each_entry_safe()都可以但是如果查出来要进行删除操作就需要用list_for_each_entry_safe()否则会宕机。具体原因可以自己查看实现。 rootubuntu:/home/Ctest/clistTest# gcc -o test listtest.c -I /usr/src/linux-hwe-5.4-headers-5.4.0-150/scripts/kconfig/ -DTEST_TRUE rootubuntu:/home/Ctest/clistTest# ./test 1 ----------------add--------------------- pstStu_out-stStu.age10,grade100 pstStu_out-stStu.age11,grade101 pstStu_out-stStu.age12,grade102 pstStu_out-stStu.age13,grade103 pstStu_out-stStu.age14,grade104 ----------------del--------------------- pstStu_out-stStu.age10,grade100 pstStu_out-stStu.age593,grade0 Segmentation fault (core dumped) rootubuntu:/home/Ctest/clistTest# gcc -o test listtest.c -I /usr/src/linux-hwe-5.4-headers-5.4.0-150/scripts/kconfig/ rootubuntu:/home/Ctest/clistTest# ./test 1 ----------------add--------------------- pstStu_out-stStu.age10,grade100 pstStu_out-stStu.age11,grade101 pstStu_out-stStu.age12,grade102 pstStu_out-stStu.age13,grade103 pstStu_out-stStu.age14,grade104 ----------------del--------------------- pstStu_out-stStu.age10,grade100 pstStu_out-stStu.age12,grade102 pstStu_out-stStu.age13,grade103 pstStu_out-stStu.age14,grade104 rootubuntu:/home/Ctest/clistTest#

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/87946.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

全网网站推广浙江建设职业技术学校网站登录

前言Spring的声明式事务让我们不在编写获得连接、关闭连接、开启事务、提交事务、回滚事务等代码,通过一个简单的Transactional注解,就让我们轻松进行事务处理。我们知道Spring事务基于AOP,采用动态代理实现,虽然使用简单&#xf…

学生个人网站设计徐州金网网站建设

开发语言 node.js 框架:Express 前端:Vue.js 数据库:mysql 数据库工具:Navicat 开发软件:VScode本论文拟采用计算机技术设计并开发的论坛bbs系统,主要是为用户提供服务。使得用户可以在系统上查看帖子信息、签到积分等…

免费html网页模板网站重庆建设工程招标投标交易信息网

print()、input()、if/else就可以做一个简陋的游戏 print() # 打印函数,将信息打印出来input() # 将信息打印,并且要求输入一段话,并且把这段话。input函数,这个函数会将字符串显示在IDLE上,并且让用户输入信息&#…

一个做外汇的网站叫熊猫什么的高大上企业网站

在当今高度竞争的制造行业中,高效的生产管理是企业成功的关键。盘古信息IMS-MOM制造运营管理系统作为一款领先的管理系统其关键特性为制造企业构建生产现场管理信息系统提供了强大的优势。IMS-MOM不仅仅是一个软件系统,更是一种技术和管理手段的结合&…

官方网站的作用网站服务器防火墙设置

呼叫中心发展至今,它的意义早已不是90年代末,只是简单地解决客户客服系统的要求。现在的呼叫中心有了新的使命,比如拓展成为一个信息服务中心,或者成为一个营销中心。客户如何能通过这样的手段,使企业与其他的企业之间形成差异化的…

哪个公司做的网站好郑州三附院不孕不育科专家

说明:该文属于 大前端全栈架构白宝书专栏,目前阶段免费,如需要项目实战或者是体系化资源,文末名片加V!作者:哈哥撩编程,十余年工作经验, 从事过全栈研发、产品经理等工作,目前在公司…

精品网站建设比较好深圳酒店vi设计公司

build.gradle(app)中设置 1. defaultConfig { multiDexEnabled true } 2. dependencies { compile ‘com.android.support:multidex:1.0.1’ } 3.使用 extends MultiDexApplication

网站基础建设和维护重庆网站建设 熊掌号

中新社吉隆坡1月30日电 (记者 陈悦)马来西亚国际贸易和工业部30日发布的2018年马来西亚贸易报告显示,2018年马来西亚与中国的贸易额约为3138.1亿林吉特(马来西亚货币,约合774亿美元),较上年同期增长8.1%,约占马来西亚对外贸易总额…

骨干校建设验收网站windows优化大师有哪些功能

写在前面:博主是一只经过实战开发历练后投身培训事业的“小山猪”,昵称取自动画片《狮子王》中的“彭彭”,总是以乐观、积极的心态对待周边的事物。本人的技术路线从Java全栈工程师一路奔向大数据开发、数据挖掘领域,如今终有小成…

linux网站入口wordpress付费发布

我的罗里吧嗦的,根据小朋友的要求,边听边写边输入的提示词: 请生成一段完整的在网页中用html5和javascript代码模拟“我的世界”中游戏场景的互动画面,要求提供若干人物选项可以选择,请自行选择需要使用哪些库或框架来…

公司网站页面设计怎样写网站设计意义

首先,这篇文章是基于笔尖AI写作进行文章创作的,喜欢的宝子,也可以去体验下,解放双手,上班直接摸鱼~ 按照惯例,先介绍下这款笔尖AI写作,宝子也可以直接下滑跳过看正文~ 笔尖Ai写作:…

物流企业网站建设策划书好用的网站推荐

什么是优质服务?既是以客户为中心的庄严承诺,又是对服务能力提升的深耕细作;既是对服务标准的敬畏,也是对服务创新的不断探索……服务是多维的,每个企业都有自己独到的诠释,或事无巨细环环严控,…

aspx网站做app建好网站是不是每年都要交钱

很久没更新了,最近准备研究逆向和加固,于是跟着看雪hanbing老师学习彻底搞懂ollvm,终于把所有流程跑通了,中间遇到了太多的坑,所以必须记录一下,能避免自己和帮助他人最好。 环境搭建太重要了,…

广州市外贸网站建设服务机构汕头资讯网

关于光纤收发器的工作原理以及使用方法这块,在这里飞畅科技的小编做了专门的整理,首先,我们来了解下什么是光纤收发器,光纤收发器是一种将短距离的双绞线电信号和长距离的光信号进行互换的以太网传输媒体转换单元,在很…

南充网站建设与维护wordpress建站网页无法运

今天复习了springMVC的框架搭建。 思维导图: 转载于:https://www.cnblogs.com/kangy123/p/9315919.html

枣庄专业三合一网站开发工程建设管理网站

蓝桥杯前端Web赛道-输入搜索联想 题目链接:1.输入搜索联想 - 蓝桥云课 (lanqiao.cn) 题目要求: 题目中还包含effect.gif 更详细的说明了需求 那么观察这道题需要做两件事情 把表头的每一个字母进行大写进行模糊查询 这里我们会用到几个js函数&#…

韩国设计网站推荐wp网站开发

杨__羊羊在哪里放置 JavaScript 代码?通常情况下,JavaScript 代码是和 HTML 代码一起使用的,可以将 JavaScript 代码放置在 HTML 文档的任何地方。但放置的地方,会对 JavaScript 代码的正常执行会有一定影响,具体如下所…

哪个网站帮忙做户型方案网络架构配置

简介 DataBinding是Google在18年推出的数据绑定框架,采用了MVVM模式来降低各模块之间代码的耦合度,使得整体代码逻辑设计更加清晰。众所周知,MVVM类似于MVC,主要目的是为分离View(视图)和Model&#xff08…

怎么样让网站网址有图标城乡建设部网站甘红刚

一:匿名内部类/非静态内部类 匿名内部类的泄漏原因:匿名内部类会隐式地持有外部类的引用.当外部类被销毁时,内部类并不会自动销毁,因为内部类并不是外部类的成员变量, 它们只是在外部类的作用域内创建的对象,所以内部…

攻击网站常用方法类似一起做网店的网站

着色器(Shader)是运行在GPU上的小程序,这些小程序为图形渲染管线的某个特定部分而运行,从基本意义上来说,着色器只是一种把输入转化为输出的程序。 一、着色器类QOpenGLShaderProgram QOpenGLShaderProgram是Qt中对着…