[ofw] [RFC] [PATCH 3/4] index list: new component to map quickly from an index to a pointer

Sean Hefty sean.hefty at intel.com
Tue Apr 22 21:09:00 PDT 2008


>So you maintain two lists - one of free items, the first entry pointed to by
>FreeList and the other at pArray[0].Entry.Next, right?  A comment or two
>wouldn't hurt, too - it would make it easier to review the code.

Correct - there are two lists.  Free list is a singly-linked list.  The 'in-use'
list head is array[0], and is a doubly-linked list.

>>+typedef struct _INDEX_LIST_ENTRY
>>+{
>>+       SIZE_T                          Next;
>>+       SIZE_T                          Prev;
>>+
>>+}      INDEX_LIST_ENTRY;
>
>Not sure what the INDEX_LIST_ENTRY structure does for you since you never use
>it except to make your notation Entry.Next rather than simply Next.

Actually, I don't need it anymore since I reserve array[0] as the head of the
list.  (Previous incarnations used an actual LIST_ENTRY, and also had a separate
LIST_ENTRY head.  This patch ended up being a more efficient.)

>>>+static void *IndexListRemoveFirst(INDEX_LIST *pIndexList)
>>+{
>>+       return IndexListRemove(pIndexList, pIndexList->pArray[0].Entry.Next);
>>+}
>
>Doesn't this remove the last entry added to the index, not the first?

I should rename this to IndexListRemoveHead(), since it removes the item at the
head of the list.  It's only called to remove items during cleanup.

- Sean 




More information about the ofw mailing list