title: How to create an std::string from a malloc-ed one?
body: <p>My C++ code uses a C function, which returns a <code>malloc</code>-ed string (allocated by <code>asprintf</code>, actually). The rest of the C++ code uses <code>std::string</code>, so, currently, the interface looks like:</p>
  <pre><code>    string
      mycppfunction(.....)
      {
      ...
          char *cresult = theCfunction(....);
          string result = cresult;
          free(cresult);
          return result;
      }
  </code></pre>
  <p>The <em>copying</em> involved in creating <code>result</code> from <code>cresult</code> annoys me -- we already have a perfectly good buffer with the text we want, yet we copy it out (wasting time and risking <code>ENOMEM</code>) and then free it...</p>
  <p>Is there a standards-blessed way of dealing with this pattern without such waste?</p>