本文整理了Java中com.sun.jna.Native.malloc()
方法的一些代码示例,展示了Native.malloc()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Native.malloc()
方法的具体详情如下:
包路径:com.sun.jna.Native
类名称:Native
方法名:malloc
[英]Call the real native malloc
[中]
代码示例来源:origin: net.java.dev.jna/jna
protected static long malloc(long size) {
return Native.malloc(size);
}
代码示例来源:origin: org.caffinitas.ohc/ohc-core
public long allocate(long size)
{
try
{
return Native.malloc(size);
}
catch (OutOfMemoryError oom)
{
return 0L;
}
}
代码示例来源:origin: yahoo/HaloDB
public long allocate(long size) {
try {
return Native.malloc(size);
} catch (OutOfMemoryError oom) {
return 0L;
}
}
代码示例来源:origin: snazy/ohc
public long allocate(long size)
{
try
{
return Native.malloc(size);
}
catch (OutOfMemoryError oom)
{
return 0L;
}
}
代码示例来源:origin: org.apache.cassandra/cassandra-all
public static long allocate(long size)
{
return Native.malloc(size);
}
代码示例来源:origin: jsevellec/cassandra-unit
public static long allocate(long size)
{
return Native.malloc(size);
}
代码示例来源:origin: com.netflix.sstableadaptor/sstable-adaptor-cassandra
public static long allocate(long size)
{
return Native.malloc(size);
}
代码示例来源:origin: com.strapdata.cassandra/cassandra-all
public static long allocate(long size)
{
return Native.malloc(size);
}
代码示例来源:origin: org.elasticsearch/jna
protected static long malloc(long size) {
return Native.malloc(size);
}
代码示例来源:origin: org.cojen/tupl
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;
}
代码示例来源:origin: cojen/Tupl
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;
}
代码示例来源:origin: com.truward.tupl/tupl
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;
}
代码示例来源:origin: com.orientechnologies/orientdb-core
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());
代码示例来源:origin: brettwooldridge/NuProcess
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");
}
}
代码示例来源:origin: com.orientechnologies/orientdb-core
final long pointer = Native.malloc(size);
if (pointer == 0) {
throw new ODirectMemoryAllocationFailedException("Can not allocate direct memory chunk of size " + size);
内容来源于网络,如有侵权,请联系作者删除!