DirectBuffers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sriram sarma
    New Member
    • Feb 2012
    • 1

    DirectBuffers

    Hi,

    My requirement is to use Direct Buffers and share a common memory between Java and C++.

    I have created a ByteBuffer in java using allocateDirect and sent the same to JNI. In JNI i have called GetDirectBuffer Address() and got the address of ByteBuffer and sent the same to my C++ library as char* through SetByteBuffer() function.

    Now i have to do getByteBuffer() from Java, which should return me the direct allocated buffer. In C++ i am returning the same char* pointer in GetByteBuffer() method and JNI is able to get the elements properly. Now i am dont now how to send this char* to Java as ByteBuffer or jByteArray() with out creating a new memory and copying the data. Can any one provide a solution to me.
Working...