<div dir="ltr">On Wed, May 6, 2015 at 5:39 PM, Huaicheng Li <span dir="ltr"><<a href="mailto:lhcwhu@gmail.com" target="_blank">lhcwhu@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">In my understanding, the head initialised using LIST_HEAD_INIT or defined by LIST_HEAD corresponds to no *real* data field. <br>But it *does* have its own _next_ and _prev_ pointers. The _next_ pointer points to the first real node in the doubly linked list,<br>and the _prev_ pointer points to the last real node. <br><br>I'm wondering if the picture shown at the very bottom of <u><a href="http://kernelnewbies.org/FAQ/LinkedLists" target="_blank">http://kernelnewbies.org/FAQ/LinkedLists</a></u> is wrong about this. Because<br>I believe head's _prev_ should point to the last node, which is at the very right. And the last node's _next_ should point to the head.<br>Just as shown like the red line.<div><br>Am I right?</div><div><br></div><div><br><div><br></div></div></div></blockquote><div><br><br></div></div></div><div>Hi Huachieng<br><br></div><div>AFAIK, if the linked list is not circular one, the last node's next should point to NULL, so does the head prev's. This is done so you know when you hit head i.e<br><br></div><div>if !(head.prev)<br>{<br></div><div> // we're at head<br></div><div>}<br></div></div><span class="HOEnZb"><font color="#888888">
</font></span></div></div>
</div><br><br clear="all"><br>-- <br><div class="gmail_signature">regards,<br><br>Mulyadi Santosa<br>Freelance Linux trainer and consultant<br><br>blog: <a href="http://the-hydra.blogspot.com" target="_blank">the-hydra.blogspot.com</a><br>training: <a href="http://mulyaditraining.blogspot.com" target="_blank">mulyaditraining.blogspot.com</a></div>
</div>