<< | Thread Index | >> ]    [ << | Date Index | >> ]

Subject: Re: Bug in list management?
From: Damion Wilson <dkw,AT,rcm,DOT,bm>
Date: Fri, 20 Apr 2001 01:38:40 +0200
In-reply-to: <B3F97C5A98D70F4EB72A31F79AEC6287026780@EXCHANGE.dmz.twobyfour.se>

Aha ! Almost, but not quite. In the following snippet from ListAdd, we see
what does happen

        else if ((l_Node = (LNODE) MemAlloc (sizeof (struct LNODESTRUCT)))
== 0) // New node is created with uninitialized memory
        else if (p_Root->m_First)     //  If the list is already populated
            (l_Node->m_Previous = p_Root->m_Last)->m_Next = l_Node; // The
new node's previous and next fields are BOTH initialized to valid values
            l_Return = l_Node->m_Payload = p_Payload;
            p_Root->m_Last = l_Node;                                       
                   // The list's last node is set to the new node
        else // If the list is empty
            l_Return = l_Node->m_Payload = p_Payload;
            p_Root->m_First = p_Root->m_Last = l_Node;
            l_Node->m_Next = l_Node->m_Previous = 0;  // The new node's
previous and next pointers are initialized to zero
            p_Root->m_Count = 1;

A new node being added to a populated list inherits m_Last's1 m_Next
pointer. A new node added to an empty list has its m_Next pointer set to
zero and becomes the m_Last node of the list at the same time, establishing
the inheritance chain. Your diagram shows the m_Previous of the first node
and the m_Next of the last node as being undefined, which is not the case.
Thus, initializing the memory to zero doesn't add any value to the
algorithm, but I now do it in MemAlloc anyway because I might use the
memory for some reason other than linked lists :-)

Thanks, anyway. Now I'll have to look somewhere else. The cipsrvr.sys I
sent you will probably die the same way as the only difference is the
memory clearing.


On Thursday, April 19, 2001 at 14:05:17 [ADT] Erik Wallin wrote:
> I've started looking at the list management. It looks like one pointer
> in the appended new list element is uninitialized in ListAdd. Check out
> the attached GIF image.
> Or does MemAlloc initialize the memory to all 0?
> I'll get back with more information when I've proof read all the list
> code. Just a quick email to get you going if I'm on the right track.
> I'm attaching a Visio version also.
> /Erik Wallin
> (erikw,AT,sec,DOT,se)

<< | Thread Index | >> ]    [ << | Date Index | >> ]