October 2017
Intermediate to advanced
586 pages
14h 8m
English
To create new nodes, just create our data struct instances and initialize their embedded list_head field. Using the car example will give the following:
struct car *blackcar = kzalloc(sizeof(struct car), GFP_KERNEL); /* non static initialization, since it is the embedded list field*/ INIT_LIST_HEAD(&blackcar->list);
As we said earlier, use INIT_LIST_HEAD, which is a dynamically allocated list and usually part of another structure.