title: libuv and uv_buf_init: who should free what?
body: <p>Consider the official <a href="http://docs.libuv.org/en/v1.x/misc.html" rel="nofollow">documentation</a> for <em>libuv</em> (section <em>miscellaneous utilities</em>).<br>
  This is the declaration of <code>uv_buf_init</code>:</p>
  
  <pre><code>uv_buf_t uv_buf_init(char* base, unsigned int len)
  </code></pre>
  
  <p>The documentation states that (emphasis mine):</p>
  
  <blockquote>
    <p>Constructor for uv_buf_t.</p>
    
    <p>Due to platform differences the user cannot rely on the ordering of the base and len members of the uv_buf_t struct. <strong>The user is responsible for freeing base after the uv_buf_t is done</strong>. Return struct passed by value.</p>
  </blockquote>
  
  <p>It seems to me that <code>base</code> can be freed immediately after a call to <code>uv_buf_init</code>.</p>
  
  <p>On the other side, a <code>uv_buf_t</code> structure <a href="http://docs.libuv.org/en/v1.x/misc.html#c.uv_buf_t" rel="nofollow">is documented</a> as composed by two fields: <code>base</code>, that has type <code>char *</code>, and <code>len</code>, that has type <code>size_t</code>.</p>
  
  <p>What is not clear to me is:</p>
  
  <ul>
  <li><p>Are data copied over into the buffer? (Well, I guess the answer is no, for it would be a great penalty in terms of performance).</p></li>
  <li><p>Should I free the data once a call to <code>uv_try_write</code> or the other <code>*_write</code> functions is done instead? That is, once the data have been actually consumed indeed.</p></li>
  </ul>