@Override public void postInvoke(Pointer[] pointers, long[] primitive, ToNativeContext context) { if (pointers != null && primitive != null) { MemoryManager mm = runtime.getMemoryManager(); for (int i = 0; i < pointers.length; i++) { pointers[i] = mm.newPointer(primitive[i]); } } } }
/** * Allocates a new block of native memory and wraps it in a {@link Pointer} * accessor. * * @param size The size in bytes of memory to allocate. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocateDirect(Runtime runtime, int size) { return runtime.getMemoryManager().allocateDirect(size); }
/** * Wraps a native address in a {@link Pointer} instance. * * @param runtime the {@code Runtime} of the pointer. * @param address the {@code address} to wrap in a Pointer instance. * * @return a {@code Pointer} instance. */ public static Pointer wrap(Runtime runtime, long address) { return runtime.getMemoryManager().newPointer(address); }
@Override public void postInvoke(Pointer[] pointers, long[] primitive, ToNativeContext context) { if (pointers != null && primitive != null) { MemoryManager mm = runtime.getMemoryManager(); for (int i = 0; i < pointers.length; i++) { pointers[i] = mm.newPointer(primitive[i]); } } } }
/** * Allocates a new block of java memory and wraps it in a {@link Pointer} * accessor. * * @param runtime The current runtime. * @param size The size in bytes of memory to allocate. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocate(Runtime runtime, int size) { return runtime.getMemoryManager().allocate(size); }
/** * Allocates a new block of native memory and wraps it in a {@link Pointer} * accessor. * * @param runtime The current runtime. * @param size The size in bytes of memory to allocate. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocateDirect(Runtime runtime, int size) { return runtime.getMemoryManager().allocateDirect(size); }
/** * Allocates a new block of java memory and wraps it in a {@link Pointer} * accessor. * * @param runtime The current runtime. * @param type The type to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocate(Runtime runtime, Type type) { return runtime.getMemoryManager().allocate(type.size()); }
/** * Allocates a new block of java memory and wraps it in a {@link Pointer} * accessor. * * @param runtime The current runtime. * @param type The native type to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocate(Runtime runtime, NativeType type) { return runtime.getMemoryManager().allocate(runtime.findType(type).size()); }
/** * Allocates a new block of java memory and wraps it in a {@link Pointer} * accessor. * * @param type The native type to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocate(Runtime runtime, NativeType type) { return runtime.getMemoryManager().allocate(runtime.findType(type).size()); }
/** * Allocates a new block of native memory and wraps it in a {@link Pointer} * accessor. * * @param runtime The current runtime. * @param type The native type to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocateDirect(Runtime runtime, NativeType type) { return runtime.getMemoryManager().allocateDirect(runtime.findType(type).size()); }
/** * Allocates a new block of java memory and wraps it in a {@link Pointer} * accessor. * * @param type The type alias to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocate(Runtime runtime, TypeAlias type) { return runtime.getMemoryManager().allocate(runtime.findType(type).size()); }
/** * Allocates a new block of native memory and wraps it in a {@link Pointer} * accessor. * * @param type The type alias to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocateDirect(Runtime runtime, TypeAlias type) { return runtime.getMemoryManager().allocateDirect(runtime.findType(type).size()); }
/** * Allocates a new block of native memory and wraps it in a {@link Pointer} * accessor. * * @param runtime The current runtime. * @param type The type alias to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocateDirect(Runtime runtime, TypeAlias type) { return runtime.getMemoryManager().allocateDirect(runtime.findType(type).size()); }
/** * Allocates a new block of native memory and wraps it in a {@link Pointer} * accessor. * * @param runtime The current runtime. * @param type The type alias to allocate memory for. * * @return a {@code Pointer} instance that can access the memory. */ public static Pointer allocateDirect(Runtime runtime, TypeAlias type) { return runtime.getMemoryManager().allocateDirect(runtime.findType(type).size()); }
public void setName(String name) { if (name == null) { setNamePointer(null); setNameLen(0); return; } byte[] nameBytes = name.getBytes(Charset.forName("US-ASCII")); Pointer p = Runtime.getSystemRuntime().getMemoryManager().allocateTemporary(nameBytes.length, true); p.put(0, nameBytes, 0, nameBytes.length); setNamePointer(p); setNameLen(nameBytes.length); }
public void setName(String name) { if (name == null) { setNamePointer(null); setNameLen(0); return; } byte[] nameBytes = name.getBytes(Charset.forName("US-ASCII")); Pointer p = Runtime.getSystemRuntime().getMemoryManager().allocateTemporary(nameBytes.length, true); p.put(0, nameBytes, 0, nameBytes.length); setNamePointer(p); setNameLen(nameBytes.length); }
public void setIov(ByteBuffer[] buffers) { Pointer iov = Runtime.getSystemRuntime().getMemoryManager().allocateDirect(BaseIovec.layout.size() * buffers.length); for (int i = 0; i < buffers.length; ++i) { Pointer eachIovecPtr = iov.slice(BaseIovec.layout.size() * i); BaseIovec eachIovec = new BaseIovec(posix, eachIovecPtr); eachIovec.set(buffers[i]); } setIovPointer(iov); setIovLen(buffers.length); }
public void setIov(ByteBuffer[] buffers) { Pointer iov = Runtime.getSystemRuntime().getMemoryManager().allocateDirect(BaseIovec.layout.size() * buffers.length); for (int i = 0; i < buffers.length; ++i) { Pointer eachIovecPtr = iov.slice(BaseIovec.layout.size() * i); BaseIovec eachIovec = new BaseIovec(posix, eachIovecPtr); eachIovec.set(buffers[i]); } setIovPointer(iov); setIovLen(buffers.length); }
public void setIov(ByteBuffer[] buffers) { Pointer iov = Runtime.getSystemRuntime().getMemoryManager().allocateDirect(BaseIovec.layout.size() * buffers.length); for (int i = 0; i < buffers.length; ++i) { Pointer eachIovecPtr = iov.slice(BaseIovec.layout.size() * i); BaseIovec eachIovec = new BaseIovec(posix, eachIovecPtr); eachIovec.set(buffers[i]); } setIovPointer(iov); setIovLen(buffers.length); }
public final void set(java.lang.String value) { if (value != null) { valueHolder = getRuntime().getMemoryManager().allocateDirect(length() * 4); valueHolder.putString(0, value, length() * 4, charset); getMemory().putPointer(offset(), valueHolder); } else { this.valueHolder = null; getMemory().putAddress(offset(), 0); } } }