Hello all:
What’s the best method of traversing a list of structures that include
a LIST_ENTRY member?
I’m looking for something like:
for(i = 0;i < number of members;i++)
{
do some operation of each member
}
I’m guessing it’ll somehow include the usage of CONTAINING_RECORD but
haven’t yet been able to figure it out.
Thanks,
Chuck
The LIST_ENTRY’s link together directly. Pointers are to LIST_ENTRYs.
Use CONTAINING_RECORD to back out to the structure which contains the
LIST_ENTRY. The macro should be self describing if you look at the
definition. Compare it to FIELD_OFFSET.
-----Original Message-----
From: chuck m [mailto:chuck.monarch@hp.com]
Sent: Tuesday, April 01, 2003 10:26 AM
To: File Systems Developers
Hello all:
What’s the best method of traversing a list of structures that
include
a LIST_ENTRY member?
I’m looking for something like:
for(i = 0;i < number of members;i++)
{
do some operation of each member
}
I’m guessing it’ll somehow include the usage of CONTAINING_RECORD but
haven’t yet been able to figure it out.
Thanks,
Chuck
You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
One of them is:
typedef struct _YOUR_STRUCT {
// Any fields
LIST_ENTRY ListEntry;
// Any fields
} YOUR_STRUCT, *PYOUR_STRUCT;
LIST_ENTRY YourListHead;
PLIST_ENTRY Entry, Head;
PYOUR_STRUCT YourStruct;
Entry = Head = &YourListHead;
while (Entry->Flink != Head) {
YourStruct = CONTAINING_RECORD(Entry->Flink, YOUR_STRUCT, ListEntry);
// Do whatever you like
Entry = Entry->Flink;
}
“Daniel Lovinger” wrote in message
news:xxxxx@ntfsd…
The LIST_ENTRY’s link together directly. Pointers are to LIST_ENTRYs.
Use CONTAINING_RECORD to back out to the structure which contains the
LIST_ENTRY. The macro should be self describing if you look at the
definition. Compare it to FIELD_OFFSET.
-----Original Message-----
From: chuck m [mailto:chuck.monarch@hp.com]
Sent: Tuesday, April 01, 2003 10:26 AM
To: File Systems Developers
Hello all:
What’s the best method of traversing a list of structures that
include
a LIST_ENTRY member?
I’m looking for something like:
for(i = 0;i < number of members;i++)
{
do some operation of each member
}
I’m guessing it’ll somehow include the usage of CONTAINING_RECORD but
haven’t yet been able to figure it out.
Thanks,
Chuck
—
You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com