public void releaseResources() { _released = true; for (int i = 0; i < _fragments.length; i++) { if (_fragments[i] != null) { _fragmentCache.release(_fragments[i]); _fragments[i] = null; } } }
/** * Put this structure back onto the available cache for reuse * */ @Override public final void release(ByteArray entry) { release(entry, true); }
private static void releaseReadBuf(ByteArray buf) { _dataReadBufs.release(buf, false); }
public void releaseBuffer() { _cache.release(_buf); } }
_cache.release(ba, false);
_cache.release(ba, false); if (read < pclen) throw new IOException();
/** * Copy in to out. Caller MUST close the streams. * * @param in non-null * @param out non-null * @since 0.9.29 */ public static void copy(InputStream in, OutputStream out) throws IOException { final ByteCache cache = ByteCache.getInstance(8, 8*1024); final ByteArray ba = cache.acquire(); try { final byte buf[] = ba.getData(); int read; while ((read = in.read(buf)) != -1) { out.write(buf, 0, read); } } finally { cache.release(ba); } }
_cache.release(ba, false); if (in != null) try { in.close(); } catch (IOException ioe) {}
/** * Called as one of the endpoints for the tunnel cache pipeline (see TunnelDataMessage) * */ private void releaseFragments() { if (_releasedAfter > 0) { RuntimeException e = new RuntimeException("double free in FragmentedMessage"); _log.error("FM releaseFragments()", e); throw e; } _releasedAfter = getLifetime(); for (int i = 0; i <= _highFragmentNum; i++) { ByteArray ba = _fragments[i]; if ( (ba != null) && (ba.getData().length == TrivialPreprocessor.PREPROCESSED_SIZE) ) { _cache.release(ba); _fragments[i] = null; } } }
_cache.release(ba, false);
_cache.release(ba, false);
/** * Only call once. Caller must synch. * @since 0.9.16 */ @Override protected void releaseBufs(boolean isVerified) { if (_released) return; _released = true; super.releaseBufs(isVerified); // Do not release _curEncrypted if verified, it is passed to // NTCPConnection to use as the IV if (!isVerified) SimpleByteCache.release(_curEncrypted); Arrays.fill(_X, (byte) 0); SimpleByteCache.release(_X); if (_msg3tmp != null) { _dataReadBufs.release(_msg3tmp, false); _msg3tmp = null; } } }
private void clearData(boolean shouldFlush) { ByteArray ba = null; if (_log.shouldLog(Log.INFO) && _valid > 0) _log.info("clearData() valid = " + _valid); synchronized (_dataLock) { // flush any data, but don't wait for it if (_valid > 0 && shouldFlush) _dataReceiver.writeData(_buf, 0, _valid); _written += _valid; _valid = 0; if (_buf != null) { ba = new ByteArray(_buf); _buf = null; _valid = 0; } _dataLock.notifyAll(); } if (ba != null) { _dataCache.release(ba); } }
_dataCache.release(ba);
_cache.release(data);
return rv; } finally { cache.release(outBuf); ReusableGZIPInputStream.release(in);
_cache.release ( data, false );
_cache.release ( ba, false ); recv.streamSendAnswer ( _id, "FAILED", "BUFFER_FULL" ) ;
/** * grow (and free) the buffer as necessary * @throws IOException if the headers are too big */ private void ensureCapacity() throws IOException { if (_headerBuffer.getValid() >= MAX_HEADER_SIZE) throw new IOException("Max header size exceeded: " + MAX_HEADER_SIZE); if (_headerBuffer.getValid() + 1 >= _headerBuffer.getData().length) { int newSize = (int)(_headerBuffer.getData().length * 1.5); ByteArray newBuf = new ByteArray(new byte[newSize]); System.arraycopy(_headerBuffer.getData(), 0, newBuf.getData(), 0, _headerBuffer.getValid()); newBuf.setValid(_headerBuffer.getValid()); newBuf.setOffset(0); // if we changed the ByteArray size, don't put it back in the cache if (_headerBuffer.getData().length == CACHE_SIZE) _cache.release(_headerBuffer); _headerBuffer = newBuf; } }
_validateCache.release(ba);