<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">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><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><img src="cid:DF2BD525-A8EE-4F51-8296-C7B94C98FB61" height="102" width="132"><br><div><br></div></div></div></blockquote><div><br><br></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><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><div>--<br>Best Regards<span class="HOEnZb"><font color="#888888"><br>Huaicheng Li<br><br><br><br><br><br></font></span></div><br></div></div></div><br>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></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></div>