<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/132188>132188</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Need an ownership_holds for non-malloced memory
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          fefe17
      </td>
    </tr>
</table>

<pre>
    I have an API where you can add a buffer to a writev-style array and then later repeatedly ask the API to write what's left of the total buffers to a file descriptor.

There are two functions to add a buffer to the list. One says "free the buffer when you are done", the other says "don't free the buffer when you are done".

Usually you will call the latter one with a string constant, but you might also call it with something malloced, and then I would like to get an error if I free that malloced buffer after adding it to the batch, and I would like to tell clang when the data structure is deinitialized so it can know that it is now OK to free the buffer you gave it.

The first half could be done with a magic identifier for ownership_holds, like currently malloc is. Maybe generic?

But the second half would need a totally new attribute, like ownership_release or so.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMlM2O6zYMhZ9G3hATOHJ-F17M7UWAQdFOF-26oCXaZkeRAokew336QnKSAWbVVRCI5_DjEWVMiQdP1Kr9D7X_WeEkY4htTz1tj1UX7NK-wYifBOjh9Y83mEeKBEuYwKAHtBYQuqnvKYIEQJgjC32-JFkcAcaIC6C3ICN5cCgUIdKNUMi6BTB95JNiLGHVwjyiKH1M4KgXCH2pkCDo7o3S2qlnR2Apmcg3CXGj6ldVv_5Z-DASyBygn7wRDn6VfIPNvo6TbODdEyRcEiit-0hUju6FcybP82ZPGzwprZX-pZQEGSk-lTZ4pY8C_8fhTvtXmtC5pZzO7BwYdG4FQ8lhBU8ws4yAkCSyH8AEnwS9ZIZukiK98jAKoEthNWBZRSlcScasuqJzwZDNqud9vMEcJmfB8UdOGAaSfM0UY4jAPbw9RkF5GjyGwj7jobXZneWRZ4dixkeT7_5CeUKHflgzyQKLUkabjEyRgBNYYs_C6PhfspBCds-79uHDvLKw5Lr89_3X7Ps98BzJkHeW5WsroOeYBEZ0PZiC1a238cj3igMbYEteuGeK0IcIYfYU08i3v8fgbMqTlWnMFCN5ccs9GOC0gd9w6QgG8hTZqOay9v4xSYFLZIK3K8CaiyfKG1l22y3gaQYUidxNQs9OXwSRHGEiCBFS2FS2bey5OWNF7fa407tjfdRNNbb7k-7w0NTnXUddczo3pz0dDueD2XX9sd5jxa2u9b5udL3dNqdds9l2XXM4EO4OemvM_qh2NV2R3ca5z-smxKHilCZqt43enk6Vw45cKl8MrTN0Oc3PYv-zim0WvXTTkNSuzs8rfdkIi6P29zK2_55tydsH__JctStdQ1yqKbp2FLkl1bwqfVH6MrCMU7cx4ar0Jbvff15uMfxDRpS-FKak9OUO_dnq_wIAAP__pPKy4w">