title: Free C-malloc()'d memory in Swift?
body: <p>I'm using the Swift compiler's Bridging Header feature to call a C function that allocates memory using <code>malloc()</code>. It then returns a pointer to that memory. The function prototype is something like:</p>
  
  <pre><code>char *the_function(const char *);
  </code></pre>
  
  <p>In Swift, I use it like this:</p>
  
  <pre><code>var ret = the_function(("something" as NSString).UTF8String)
  
  let val = String.fromCString(ret)!
  </code></pre>
  
  <p>Forgive my ignorance concerning Swift but normally in C, if the_function() is malloc'ing memory and returning it, somebody else needs to free() it at some point.</p>
  
  <p>Is this being handled by Swift somehow or am I leaking memory in this example?</p>
  
  <p>Thanks in advance.</p>