title: Copy data into v8::ArrayBuffer
body: <p>I'm writing a Javascript interpreter in C++ using v8.
  I need to pass a char buffer into an ArrayBuffer so that it gets garbage collected. Here is my code:</p>
  
  <pre><code>QByteArray data_buffer(file.readAll().data(), file.size());
  
  v8::Handle&lt;v8::ArrayBuffer&gt; ab = v8::ArrayBuffer::New(args.GetIsolate(), data_buffer.size());
  //insert code to copy data from data_buffer to ab
  args.GetReturnValue().Set(ab);
  </code></pre>
  
  <p>If I use the constructor from the documentation in which I pass a pointer to the data, I'll have to deal with the memory myself and I don't want that.</p>
  
  <p>I want to avoid allocating memory and let v8 do it's own memory management.
  Couldn't find a way using Set() or any other function.</p>
  
  <p>Any suggestions on how to copy data to the arraybuffer? Or how can I use the 2 parameters constructor to let v8 deal with the memory my data uses?</p>
  
  <p>Documentation here: <a href="http://bespin.cz/~ondras/html/classv8_1_1ArrayBuffer.html" rel="nofollow">http://bespin.cz/~ondras/html/classv8_1_1ArrayBuffer.html</a> Thanks.</p>