本文整理汇总了Java中org.lwjgl.system.MemoryUtil.memRealloc方法的典型用法代码示例。如果您正苦于以下问题:Java MemoryUtil.memRealloc方法的具体用法?Java MemoryUtil.memRealloc怎么用?Java MemoryUtil.memRealloc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.system.MemoryUtil
的用法示例。
在下文中一共展示了MemoryUtil.memRealloc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSize
import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
/**
* Set the size of the buffer
* @param newCapacity The new capacity
*/
public void setSize(int newCapacity) {
if (data == null) {
data = MemoryUtil.memAlloc(newCapacity);
} else {
ByteBuffer newData = MemoryUtil.memRealloc(data, newCapacity);
if (data != null && MemoryUtil.memAddress(newData) != MemoryUtil.memAddress(data)) {
MemoryUtil.memFree(data);
data = newData;
}
}
if (capacity > newCapacity)
bufferSize = 0;
capacity = newCapacity;
}
示例2: realloc
import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
/**
* If {@code buffer} is {@code NULL}:
* <p>
* Behaves like {@link #createByteBuffer(int)}
* </p>
* If {@code buffer} is not {@code NULL}:
* <p>
* Changes the size of the memory block pointed by {@code buffer}
* maintaining the old data the same, and if is larger than before,
* the new part of memory contains undefined values. May move the
* memory into another part, so don't use the old {@code buffer}
* and use the returned one.
* </p>
* @param buffer memory block to resize
* @param newSize new size of the memory block
* @return a new buffer
*/
public static ByteBuffer realloc(ByteBuffer buffer, int newSize) {
return MemoryUtil.memRealloc(buffer, newSize);
}