title: Best practice for allocating memory for use by a function — malloc inside or outside?
body: <p>During my experience with C coding, I've seen 2 ways of passing arguments for functions:</p>
  
  <ol>
  <li><p><code>malloc</code> before calling functions</p></li>
  <li><p><code>malloc</code> inside functions (variable is not initialized before calling function)</p></li>
  </ol>
  
  <p>I, particularly, prefer the second form. But while I'm the only one to code my program, I know that, but some else could not know, and could lead to 2 <code>malloc</code>, and leak of memory.</p>
  
  <p>So, my question is: What's the best practice for this?</p>