25 messages in net.java.dev.jna.usersRe: [jna-users] Getting pointer from ...
FromSent OnAttachments
Stas OskinMar 18, 2009 4:17 am 
Timothy WallMar 18, 2009 5:46 am 
Stas OskinMar 18, 2009 6:01 am 
Stas OskinMar 18, 2009 7:27 am 
Stas OskinMar 21, 2009 1:10 pm 
Timothy WallMar 30, 2009 6:12 am 
Stas OskinMay 26, 2009 4:49 am 
Timothy WallMay 26, 2009 5:15 am 
Stas OskinMay 26, 2009 5:19 am 
Timothy WallMay 26, 2009 6:05 am 
Stas OskinMay 27, 2009 5:20 am 
Timothy WallMay 27, 2009 6:35 am 
Stas OskinMay 27, 2009 9:32 am 
Timothy WallMay 27, 2009 11:13 am 
Stas OskinMay 28, 2009 8:33 am 
Stas OskinMay 28, 2009 8:34 am 
Nikolas LotzMay 28, 2009 8:59 am 
Timothy WallMay 28, 2009 9:03 am 
Timothy WallMay 28, 2009 9:04 am 
Stas OskinMay 29, 2009 8:17 am 
Timothy WallMay 29, 2009 2:38 pm 
Stas OskinMay 30, 2009 5:54 am 
Stas OskinMay 30, 2009 7:21 am 
Timothy WallMay 30, 2009 10:32 am 
Stas OskinMay 30, 2009 5:31 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Getting pointer from pointerActions...
From:Timothy Wall (twal@dev.java.net)
Date:May 26, 2009 5:15:58 am
List:net.java.dev.jna.users

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);