NativeBuffers.java revision 2362
6982N/A * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. 6982N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5065N/A * This code is free software; you can redistribute it and/or modify it 5065N/A * under the terms of the GNU General Public License version 2 only, as 5065N/A * published by the Free Software Foundation. Oracle designates this 6982N/A * particular file as subject to the "Classpath" exception as provided 6982N/A * by Oracle in the LICENSE file that accompanied this code. 5065N/A * This code is distributed in the hope that it will be useful, but WITHOUT 5065N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 5065N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 6982N/A * version 2 for more details (a copy is included in the LICENSE file that 6982N/A * You should have received a copy of the GNU General Public License version 5065N/A * 2 along with this work; if not, write to the Free Software Foundation, 5065N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 5065N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 5065N/A * or visit www.oracle.com if you need additional information or have any * Factory for native buffers. * Allocates a native buffer, of at least the given size, from the heap. // Make a new one of at least 2k * Returns a native buffer, of at least the given size, from the thread // return from cache if possible * Returns a native buffer, of at least the given size. The native buffer * is taken from the thread local cache if possible; otherwise it is * allocated from the heap. * Releases the given buffer. If there is space in the thread local cache * then the buffer goes into the cache; otherwise the memory is deallocated. // create cache if it doesn't exist // Put it in an empty slot if such exists // Otherwise replace a smaller one in the cache if such exists * Copies a byte array and zero terminator into a given native buffer. * Copies a byte array and zero terminator into a native buffer, returning