Linked Lists

Drivers sometimes need to maintain linked list data structures. This section describes the support available for managing singly and doubly linked lists.

Singly Linked Lists

To use singly linked lists, begin by declaring a list head of type SINGLE_ LIST_ENTRY. This simplistic structure is also the data type of the linked pointer itself. Indeed, the SINGLE_LIST_ENTRY structure has but one offset: Next. The list head must be manually initialized, as demonstrated in the following code fragment.

typedef struct _DEVICE_EXTENSION {
     :
     SINGLE_LIST_ENTRY listHead;   // Declare head ptr
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
     :
pDevExt->listHead.Next = NULL;   // init the list

To add or remove entries from the front of the list, call PushEntryList ...

Get Windows® 2000 Device Driver Book: A Guide for Programmers, Second Edition, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.