<div dir="ltr">I wasn&#39;t thinking of memory management (although I agree that adopting conventions helps avoid errors in that domain).<div><br></div><div>I&#39;m thinking of the difference between truly grokking the power of multiple levels of read-write indirection.  A deep comfort with the use of pointers is what Linus Torvalds was talking about here:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><a href="http://meta.slashdot.org/story/12/10/11/0030249/linus-torvalds-answers-your-questions">http://meta.slashdot.org/story/12/10/11/0030249/linus-torvalds-answers-your-questions</a></div></blockquote><div><br></div><div>... when he talks about linked list operations.  Here&#39;s a quote:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><span style="color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px">At the opposite end of the spectrum, I actually wish more people understood the really core low-level kind of coding. Not big, complex stuff like the lockless name lookup, but simply good use of pointers-to-pointers etc. For example, I&#39;ve seen too many people who delete a singly-linked list entry by keeping track of the &quot;prev&quot; entry, and then to delete the entry, doing something like</span><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><span style="color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px">if (prev)</span><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><span style="color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px">prev-&gt;next = entry-&gt;next;</span><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><span style="color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px">else</span><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><span style="color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px">list_head = entry-&gt;next;</span><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><span style="color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px">and whenever I see code like that, I just go &quot;This person doesn&#39;t understand pointers&quot;. And it&#39;s sadly quite common.</span><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><span style="color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px">People who understand pointers just use a &quot;pointer to the entry pointer&quot;, and initialize that with the address of the list_head. And then as they traverse the list, they can remove the entry without using any conditionals, by just doing a &quot;*pp = entry-&gt;next&quot;.</span><div> </div></blockquote><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 3, 2015 at 9:03 AM, DJ-Pfulio <span dir="ltr">&lt;<a href="mailto:djpfulio@jdpfu.com" target="_blank">djpfulio@jdpfu.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Pointers are easy.<br>
<br>
Either they point to valid, allocated memory (or a function), or they point to<br>
NULL. PERIOD.  A null pointer exception is much nicer than any bug that seems to<br>
work.<br>
<br>
char* myName=NULL;<br>
<br>
myName = malloc( sizeof(&quot;1234546789&quot;) );<br>
if ( NULL == myName ) return;  /* Always validate the desired memory allocation<br>
worked */<br>
<br>
/* do something interesting ; pass myName around, into functions, etc .... */<br>
<br>
free(myName);<br>
myName=NULL;<br>
<br>
/* Any attempts to reference myName now will provide a null pointer exception<br>
and crash (throw exception). */<br>
<br>
BTW, I haven&#39;t written any C code that uses malloc() since .... 1995-ish, so<br>
don&#39;t expect that to compile cleanly.  Writing clear C code is VERY important.<br>
Sure, there are wasted statements, but there is a reason. Clarity. A good<br>
compiler will optimize out any wasted code. Some of this code will be running in<br>
50 yrs, perhaps longer. Make the source clear, always.<br>
<br>
I don&#39;t expect a SmartPtr class to manage memory for me. They tend to do things<br>
when I don&#39;t want and do it in a way different from what I&#39;d like.<br>
<br>
Simple. Good pointer management is an important skill for all programmers, even<br>
python, java, and other languages that don&#39;t provide direct access to pointers.<br>
 After all, what is a reference?  It is just a pointer.  Perl has references and<br>
they are used ALL-THE-TIME.<br>
<span class=""><br>
<br>
On 12/03/2015 08:22 AM, Ed Cashin wrote:<br>
&gt; For some reason this statement reminded me that there was a critical<br>
&gt; supplement to all the C books I read.<br>
&gt;<br>
&gt; Ted Jensen&#39;s pointer tutorial:<br>
&gt;<br>
&gt;   <a href="http://pw1.netcom.com/~tjensen/ptr/pointers.htm" rel="noreferrer" target="_blank">http://pw1.netcom.com/~tjensen/ptr/pointers.htm</a><br>
&gt;<br>
&gt; ... will eliminate any residual discomfort with pointers.  It&#39;s a gem.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Wed, Dec 2, 2015 at 3:05 PM, Boris Borisov &lt;<a href="mailto:bugyatl@gmail.com">bugyatl@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; I guess everybody is reading their C books. So quiet:)<br>
&gt;&gt;<br>
&gt;&gt; On Wednesday, December 2, 2015, Scott M. Jones &lt;<a href="mailto:eff@dragoncon.org">eff@dragoncon.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; <a href="http://talky.io" rel="noreferrer" target="_blank">talky.io</a> claims to do screen sharing.  That&#39;s why I&#39;d like to test to<br>
&gt;&gt;&gt; see how well it works, and if it works at all for bare metal Linux.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; <a href="https://about.talky.io" rel="noreferrer" target="_blank">https://about.talky.io</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On 12/2/15 11:30 AM, DjPfulio wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; The problem with web RTC is its only webcam based; how do we share<br>
&gt;&gt;&gt;&gt; screens through it? that&#39;s the problem.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On 2 December 2015 10:08:09 GMT-05:00, &quot;Scott M. Jones&quot;<br>
&gt;&gt;&gt;&gt; &lt;<a href="mailto:eff@dragoncon.org">eff@dragoncon.org</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;     On 11/26/15 6:41 AM, Leam Hall wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;         Soo...Scott, does that mean you&#39;re volunteering to be a resident<br>
&gt;&gt;&gt;&gt;         mentor? :P<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;     I&#39;d be interested in helping to the extent that I can.  We went to<br>
&gt;&gt;&gt; C++<br>
&gt;&gt;&gt;&gt;     in 2001 and Java in 2006, and sinc&gt;     options.  One possibility<br>
</span>&gt;&gt;&gt; not mentioned so far is <a href="http://talky.io" rel="noreferrer" target="_blank">talky.io</a> &lt;<a href="http://talky" rel="noreferrer" target="_blank">http://talky</a>. &lt;<a href="http://talky.io" rel="noreferrer" target="_blank">http://talky.io</a>&gt;&gt;<br>
&gt;&gt;&gt; __________<br>
<div class="HOEnZb"><div class="h5">&gt;&gt;<br>
&gt;&gt;<br>
_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" rel="noreferrer" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" rel="noreferrer" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">  Ed Cashin &lt;<a href="mailto:ecashin@noserose.net" target="_blank">ecashin@noserose.net</a>&gt;</div></div>
</div>