<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Typed Arrays have no public facing API"
   href="https://bugs.webkit.org/show_bug.cgi?id=120112#c20">Comment # 20</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Typed Arrays have no public facing API"
   href="https://bugs.webkit.org/show_bug.cgi?id=120112">bug 120112</a>
              from <span class="vcard"><a class="email" href="mailto:fpizlo&#64;apple.com" title="Filip Pizlo &lt;fpizlo&#64;apple.com&gt;"> <span class="fn">Filip Pizlo</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=120112#c19">comment #19</a>)
<span class="quote">&gt; &gt; Referenced.  For example the &quot;keep&quot; argument could be interpreted as:
&gt; &gt; 
&gt; &gt; keep=true: we call the system free() on the original void* when we decide to
&gt; &gt; free the buffer.
&gt; &gt; 
&gt; &gt; keep=false: we don't free the original void* buffer when we free the array
&gt; &gt; buffer, and the only way that the client can be sure that we no longer want
&gt; &gt; the backing data is when they destroy the VM.
&gt; 
&gt; These options don't seem very good to me in a general purpose API.
&gt; 
&gt; We can't assume that our client used malloc. They might have used new, mmap,
&gt; objc_createInstance, or a custom allocator.
&gt; 
&gt; Requiring a valid pointer for the lifetime of the VM is a difficult model to
&gt; program with. For example, we couldn't use that model in the browser, or in
&gt; the audio processing context being discussed on webkit-dev.
&gt; 
&gt; &gt; Having a free callback would be even better.
&gt; 
&gt; This seems more reasonable to me.
&gt; 
&gt; It would be nice if we didn't have to reinvent a generic API for &quot;referenced
&gt; counted data pointer&quot;. Perhaps we can write this API in terms of
&gt; CFMutableDataRef and NSMutableData.</span >

Hmmm, that's a good point.  NSData already has everything we need:

- We can return a NSData or CFDataRef when someone asks for a raw pointer to a typed array.  The NSData would have a deallocator that decrements our internal buffer ref count.

- We can create an array buffer when given a NSData. It would be easy to modify our internal ArrayBuffer code to make it capable of calling a custom destructor and/or just [object release].</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>