Lines Matching refs:buffer
44 * Allocates a native buffer, of at least the given size, from the heap.
53 * Returns a native buffer, of at least the given size, from the thread
61 NativeBuffer buffer = buffers[i];
62 if (buffer != null && buffer.size() >= size) {
64 return buffer;
72 * Returns a native buffer, of at least the given size. The native buffer
77 NativeBuffer buffer = getNativeBufferFromCache(size);
78 if (buffer != null) {
79 buffer.setOwner(null);
80 return buffer;
87 * Releases the given buffer. If there is space in the thread local cache
88 * then the buffer goes into the cache; otherwise the memory is deallocated.
90 static void releaseNativeBuffer(NativeBuffer buffer) {
95 buffers[0] = buffer;
102 buffers[i] = buffer;
109 if (existing.size() < buffer.size()) {
111 buffers[i] = buffer;
117 buffer.cleaner().clean();
121 * Copies a byte array and zero terminator into a given native buffer.
123 static void copyCStringToNativeBuffer(byte[] cstr, NativeBuffer buffer) {
126 // assert buffer.size() >= (len + 1);
127 // unsafe.copyMemory(cstr, offset, null, buffer.address(), len);
128 // unsafe.putByte(buffer.address() + len, (byte)0);
132 assert buffer.size() >= (len + 1);
134 unsafe.putByte(buffer.address() + i, cstr[i]);
136 unsafe.putByte(buffer.address() + len, (byte)0);
140 * Copies a byte array and zero terminator into a native buffer, returning
141 * the buffer.
144 NativeBuffer buffer = getNativeBuffer(cstr.length+1);
145 copyCStringToNativeBuffer(cstr, buffer);
146 return buffer;