#include<linux/rbtree.h>
#include <linux/string.h>
#include "kn_common.h"
MODULE_LICENSE("Dual BSD/GPL");
struct student
{
int id;
char* name;
struct rb_node node;
};
static int insert_student(struct student*, struct rb_root*);
static int remove_student(struct student*, struct rb_root*);
static int display_student(struct rb_root*, int);
static void display_student_from_small(struct rb_node*);
static void display_student_from_big(struct rb_node*);
static void print_student(struct student*);
static int testrbtree_init(void)
{
#define N 10
struct rb_root root = RB_ROOT;
struct student *stu[N];
char tmp_name[5] = {'w', 'y', 'b', '0', '\0'};
int i;
// init N struct student
for (i=0; i<N; i++)
{
stu[i] = kmalloc(sizeof(struct student), GFP_KERNEL);
stu[i]->id = i;
stu[i]->name = kmalloc
linux内核分析--内核中的数据结构之红黑树(续)
最新推荐文章于 2022-05-13 14:43:12 发布
这篇博客深入探讨了Linux内核中的红黑树数据结构,结合kn_common.h和kn_common.c文件进行分析,讲解如何在内核模块中使用和理解红黑树。
摘要由CSDN通过智能技术生成