com.sun.jna.Native.free()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(286)

本文整理了Java中com.sun.jna.Native.free()方法的一些代码示例,展示了Native.free()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Native.free()方法的具体详情如下:
包路径:com.sun.jna.Native
类名称:Native
方法名:free

Native.free介绍

[英]Call the real native free
[中]称真正的本地人为自由人

代码示例

代码示例来源:origin: net.java.dev.jna/jna

protected static void free(long p) {
  // free(0) is a no-op, so avoid the overhead of the call
  if (p != 0) {
    Native.free(p);
  }
}

代码示例来源:origin: com.orientechnologies/orientdb-core

@Override
public void freeBinaryContent() {
 if (pointer > 0) {
  Native.free(pointer);
 }
 this.pointer = 0;
 this.binaryContent = null;
}

代码示例来源:origin: org.elasticsearch/jna

protected static void free(long p) {
  // free(0) is a no-op, so avoid the overhead of the call
  if (p != 0) {
    Native.free(p);
  }
}

代码示例来源:origin: org.apache.cassandra/cassandra-all

public static void free(long peer)
{
  Native.free(peer);
}

代码示例来源:origin: jsevellec/cassandra-unit

public static void free(long peer)
{
  Native.free(peer);
}

代码示例来源:origin: snazy/ohc

public void free(long peer)
{
  Native.free(peer);
}

代码示例来源:origin: com.strapdata.cassandra/cassandra-all

public static void free(long peer)
{
  Native.free(peer);
}

代码示例来源:origin: org.caffinitas.ohc/ohc-core

public void free(long peer)
{
  Native.free(peer);
}

代码示例来源:origin: com.netflix.sstableadaptor/sstable-adaptor-cassandra

public static void free(long peer)
{
  Native.free(peer);
}

代码示例来源:origin: yahoo/HaloDB

public void free(long peer) {
  Native.free(peer);
}

代码示例来源:origin: com.orientechnologies/orientdb-core

/**
 * Returns allocated direct memory back to OS
 */
public void deallocate(OPointer pointer) {
 if (pointer == null) {
  throw new IllegalArgumentException("Null value is passed");
 }
 final Pointer ptr = pointer.getNativePointer();
 Native.free(Pointer.nativeValue(ptr));
 memoryConsumption.add(-pointer.getSize());
 untrack(pointer);
}

代码示例来源: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: 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: xyz.cofe/j-libc

/**
 * Приводит имя файла (путь) в каноническую форму.
 * Удаляет точки (.), две точки (..) в имени "разрешает" до родительского каталога.
 * @param filename Имя файла
 * @return Имя файла или null, если имя файла не содержит компонентов
 */
public String canonicalizeFileName( String filename ){
  if( filename==null )throw new IllegalArgumentException( "name==null" );
  synchronized( syncObj ){
    Pointer ptr = LibC.canonicalize_file_name(filename);
    if( ptr==null ){
      return null;
    }
    if( Pointer.nativeValue(ptr)==0 ){
      return null;
    }
    String name2 = ptr.getString(0);
    Native.free(Pointer.nativeValue(ptr));
    return name2;
  }
}
//</editor-fold>

代码示例来源: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.orientechnologies/orientdb-core

Native.free(pointer);
Native.free(compressedPointer);
return new OPair<>(content, pointer);

代码示例来源: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: xyz.cofe/j-libc

if( ptr!=null )Native.free(Pointer.nativeValue(ptr));

相关文章

Native类方法