12 messages in net.java.dev.jna.usersRe: [jna-users] Getting pointers from...
FromSent OnAttachments
Douglas AdlerAug 20, 2008 12:03 pm 
Timothy WallAug 20, 2008 12:55 pm 
Wayne MeissnerAug 20, 2008 6:37 pm 
Douglas AdlerAug 21, 2008 11:56 am 
Timothy WallAug 21, 2008 12:18 pm 
Wayne MeissnerAug 21, 2008 3:47 pm 
Wayne MeissnerAug 21, 2008 3:55 pm 
Timothy WallAug 22, 2008 7:41 am 
Wayne MeissnerAug 22, 2008 3:57 pm 
Timothy WallAug 22, 2008 4:04 pm 
Wayne MeissnerAug 22, 2008 4:39 pm 
Scott PalmerAug 22, 2008 6:47 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 pointers from javaActions...
From:Wayne Meissner (wmei@gmail.com)
Date:Aug 21, 2008 3:55:17 pm
List:net.java.dev.jna.users

2008/8/22 Timothy Wall <twal@dev.java.net>:

Have you tried simply passing "int[]" to the native method instead of the direct buffer?

Unless the array is stored discontiguously, you can avoid the extra data copy altogether.

Actually, with current JVM implementations, that will result in two copies, since GetIntArrayElements will copy the int[] array to temporary native memory, then ReleaseIntArrayElements will copy the native memory back to the int[] array.

This can be avoided if the array is pinned, using GetPrimitiveArrayCritical, but currently there's no way for JNA to signal that an array should be handled that way - and we shouldn't do all arrays as pinned, since Get*ArrayCritical locks the GC until the corresponding Release*ArrayCritical is called - v.bad for native methods that might block.