 <p>Every memory block obtained via <code>malloc</code> and friends that is not freed with the <code>free</code> function will yield in a memory leak and this is toally independent of scopes.</p> <p>In other words, you may allocate a memory block in some function and free it later in a totally different function; this is actually how <code>malloc</code> and <code>free</code> are used most of the time.</p> <p><strong>Example</strong> (just for illustration purposes, not necessarily good programming practice)</p> <pre><code>char *Foo() { ... return malloc(...); } void Bar() { char *p = Foo(); ... free(p); // freeing the pointer that has been allocated in Foo } </code></pre> <p>The Wiki example causes a leak because once the function has been executed, the a pointer doesn't exist any more because it is a <em>local variable</em> that exists only during the execution time of the function.</p> <p>But the memory block itself that has been allocated and that was pointed by <code>a</code> is still allocated and now there is no more way to free it because the only pointer (<code>a</code>) that pointed to it is gone.</p>