(ByteBuffer buf, byte[] arr,
boolean wrap)
| 2377 | |
| 2378 | |
| 2379 | protected static ByteBuffer updateByteBuffer(ByteBuffer buf, byte[] arr, |
| 2380 | boolean wrap) { |
| 2381 | if (USE_DIRECT_BUFFERS || (buf != null && buf.isDirect())) { |
| 2382 | if (buf == null || buf.capacity() < arr.length) { |
| 2383 | buf = allocateDirectByteBuffer(arr.length); |
| 2384 | } |
| 2385 | buf.position(0); |
| 2386 | buf.put(arr); |
| 2387 | buf.rewind(); |
| 2388 | } else { |
| 2389 | if (wrap) { |
| 2390 | buf = ByteBuffer.wrap(arr); |
| 2391 | } else { |
| 2392 | if (buf == null || buf.capacity() < arr.length) { |
| 2393 | buf = ByteBuffer.allocate(arr.length); |
| 2394 | } |
| 2395 | buf.position(0); |
| 2396 | buf.put(arr); |
| 2397 | buf.rewind(); |
| 2398 | } |
| 2399 | } |
| 2400 | return buf; |
| 2401 | } |
| 2402 | |
| 2403 | |
| 2404 | protected static void updateByteBuffer(ByteBuffer buf, byte[] arr, |
no test coverage detected