protected static long malloc(long size) { return Native.malloc(size); }
public long allocate(long size) { try { return Native.malloc(size); } catch (OutOfMemoryError oom) { return 0L; } }
public long allocate(long size) { try { return Native.malloc(size); } catch (OutOfMemoryError oom) { return 0L; } }
public long allocate(long size) { try { return Native.malloc(size); } catch (OutOfMemoryError oom) { return 0L; } }
public static long allocate(long size) { return Native.malloc(size); }
public static long allocate(long size) { return Native.malloc(size); }
public static long allocate(long size) { return Native.malloc(size); }
public static long allocate(long size) { return Native.malloc(size); }
protected static long malloc(long size) { return Native.malloc(size); }
static String errorMessage(int errnum) { final int bufLen = 200; long bufPtr = Native.malloc(bufLen); if (bufPtr != 0) { try { long result = strerror_r(errnum, bufPtr, bufLen); if (result != -1 && result != 22 && result != 34) { // !EINVAL && !ERANGE return new Pointer(result == 0 ? bufPtr : result).getString(0); } } finally { Native.free(bufPtr); } } return "Error " + errnum; }
static String errorMessage(int errnum) { final int bufLen = 200; long bufPtr = Native.malloc(bufLen); if (bufPtr != 0) { try { long result = strerror_r(errnum, bufPtr, bufLen); if (result != -1 && result != 22 && result != 34) { // !EINVAL && !ERANGE return new Pointer(result == 0 ? bufPtr : result).getString(0); } } finally { Native.free(bufPtr); } } return "Error " + errnum; }
static String errorMessage(int errnum) { final int bufLen = 200; long bufPtr = Native.malloc(bufLen); if (bufPtr != 0) { try { long result = strerror_r(errnum, bufPtr, bufLen); if (result != -1 && result != 22 && result != 34) { // !EINVAL && !ERANGE return new Pointer(result == 0 ? bufPtr : result).getString(0); } } finally { Native.free(bufPtr); } } return "Error " + errnum; }
final ByteBuffer content; pointer = Native.malloc(contentSize); content = new Pointer(pointer).getByteBuffer(0, contentSize); final int maxCompressedLength = compressor.maxCompressedLength(contentSize - 1); final long compressedPointer = Native.malloc(maxCompressedLength + 5); final ByteBuffer compressedContent = new Pointer(compressedPointer). getByteBuffer(0, maxCompressedLength + 5).order(ByteOrder.nativeOrder());
private int spawnWithCwd(final IntByReference restrict_pid, final String restrict_path, final Pointer file_actions, final Pointer /*const posix_spawnattr_t*/ restrict_attrp, final StringArray /*String[]*/ argv, final Pointer /*String[]*/ envp, final Path cwd) { int cwdBufSize = 1024; long peer = Native.malloc(cwdBufSize); Pointer oldCwd = new Pointer(peer); LibC.getcwd(oldCwd, cwdBufSize); String newCwd = cwd.toAbsolutePath().toString(); int rc = LibC.SYSCALL.syscall(SyscallLibrary.SYS___pthread_chdir, newCwd); checkReturnCode(rc, "syscall(SYS__pthread_chdir) failed to set current directory"); try { return LibC.posix_spawnp(restrict_pid, restrict_path, file_actions, restrict_attrp, argv, envp); } finally { rc = LibC.SYSCALL.syscall(SyscallLibrary.SYS___pthread_chdir, oldCwd); Native.free(Pointer.nativeValue(oldCwd)); checkReturnCode(rc, "syscall(SYS__pthread_chdir) failed to restore current directory"); } }
final long pointer = Native.malloc(size); if (pointer == 0) { throw new ODirectMemoryAllocationFailedException("Can not allocate direct memory chunk of size " + size);