memcpy is a standard C library function. It copies the contents of
the second argument into the first.
On May 26, 2009, at 7:49 AM, Stas Oskin wrote:
Hi.
Thanks for the explanation, this makes the things clear.
Can you provide a short definition of memcpy in JNA?
Regards.
2009/3/30 Timothy Wall <twal...@dev.java.net>
On Mar 21, 2009, at 4:10 PM, Stas Oskin wrote:
Hi.
Can someone advice about this - how to create a new Pointer,
pointing to a copy of some part of the original Pointer?
Something like this:
function copy(p)
{
new_p* = malloc (30);
memcpy((p+10), new_p, 30); //Copy data from p + offset of 10
return new_p;
}
Pointer p0 = ...;
Pointer p1 = new Memory(30);
byte[] contents = new byte[30];
p0.read(10, contents, 0, 30);
p1.write(0, contents, 0, 30);
Pointer p2 = p0.share(10, 30); // still points to original memory
If you want to avoid the two copies, you can simply map memcpy itself:
// NOTE: count is actually of type size_t, which may be 64 bits on
some platforms
Pointer memcpy(Pointer dst, Pointer src, int count);
// copy 30 bytes at offset 10 from p0 to p1
lib.memcpy(p1, p0.share(10), 30);