void Decoder::Write(const char* aBuffer, uint32_t aCount) { PROFILER_LABEL("ImageDecoder", "Write"); // We're strict about decoder errors NS_ABORT_IF_FALSE(!HasDecoderError(), "Not allowed to make more decoder calls after error!"); // If a data error occured, just ignore future data if (HasDataError()) return; if (IsSizeDecode() && HasSize()) { // More data came in since we found the size. We have nothing to do here. return; } // Pass the data along to the implementation WriteInternal(aBuffer, aCount); // If we're a synchronous decoder and we need a new frame to proceed, let's // create one and call it again. while (mSynchronous && NeedsNewFrame() && !HasDataError()) { nsresult rv = AllocateFrame(); if (NS_SUCCEEDED(rv)) { // Tell the decoder to use the data it saved when it asked for a new frame. WriteInternal(nullptr, 0); } } }
void Decoder::Write(const char* aBuffer, uint32_t aCount, DecodeStrategy aStrategy) { PROFILER_LABEL("ImageDecoder", "Write", js::ProfileEntry::Category::GRAPHICS); MOZ_ASSERT(NS_IsMainThread() || aStrategy == DecodeStrategy::ASYNC); // We're strict about decoder errors MOZ_ASSERT(!HasDecoderError(), "Not allowed to make more decoder calls after error!"); // Begin recording telemetry data. TimeStamp start = TimeStamp::Now(); mChunkCount++; // Keep track of the total number of bytes written. mBytesDecoded += aCount; // If we're flushing data, clear the flag. if (aBuffer == nullptr && aCount == 0) { MOZ_ASSERT(mNeedsToFlushData, "Flushing when we don't need to"); mNeedsToFlushData = false; } // If a data error occured, just ignore future data. if (HasDataError()) return; if (IsSizeDecode() && HasSize()) { // More data came in since we found the size. We have nothing to do here. return; } // Pass the data along to the implementation WriteInternal(aBuffer, aCount, aStrategy); // If we're a synchronous decoder and we need a new frame to proceed, let's // create one and call it again. if (aStrategy == DecodeStrategy::SYNC) { while (NeedsNewFrame() && !HasDataError()) { nsresult rv = AllocateFrame(); if (NS_SUCCEEDED(rv)) { // Use the data we saved when we asked for a new frame. WriteInternal(nullptr, 0, aStrategy); } mNeedsToFlushData = false; } } // Finish telemetry. mDecodeTime += (TimeStamp::Now() - start); }
//------------------------------------------------------------------------------ void NewickTreeWriterGTP::WriteGTP () { cur = t->GetRoot(); while (cur) { if (cur->GetChild()) { WriteLeftParenthesis (); stk.push (cur); cur = cur->GetChild(); } else { WriteLeaf (); while (!stk.empty() && (cur->GetSibling() == NULL)) { WriteRightParenthesis (); cur = stk.top(); WriteInternal (); stk.pop(); } if (stk.empty()) cur = NULL; else { WriteSiblingSymbol (); cur = cur->GetSibling(); } } } WriteEndOfTree (); }
/* Empty the write buffer to disk. Return -1 on error, 0 on success. */ int RageFileObj::EmptyWriteBuf() { if( m_pWriteBuffer == NULL ) return 0; if( m_iWriteBufferUsed ) { /* The write buffer might not align with the actual file, if we've seeked. Only * seek if needed. */ bool bSeeked = (m_iWriteBufferPos+m_iWriteBufferUsed != m_iFilePos); if( bSeeked ) SeekInternal( m_iWriteBufferPos ); int iRet = WriteInternal( m_pWriteBuffer, m_iWriteBufferUsed ); if( bSeeked ) SeekInternal( m_iFilePos ); if( iRet == -1 ) return iRet; } m_iWriteBufferPos = m_iFilePos; m_iWriteBufferUsed = 0; return 0; }
int RageFileObj::Write( const void *pBuffer, size_t iBytes ) { int iRet = WriteInternal( pBuffer, iBytes ); if( iRet != -1 ) { m_iFilePos += iRet; if( m_bCRC32Enabled ) CRC32( m_iCRC32, pBuffer, iBytes ); } return iRet; }
// writes an entry to the debug log void CDXLog::Write(const char *fmt, ...) { char buff[256]; va_list va; va_start(va, fmt); //put the time in milliseconds at beginning of line. wsprintf(buff, "%u: ", timeGetTime() - m_dwStartTime); wvsprintf(&buff[lstrlen(buff)], fmt, va); lstrcat(buff, "\n"); WriteInternal(buff); }
void Decoder::Write(const char* aBuffer, PRUint32 aCount) { // We're strict about decoder errors NS_ABORT_IF_FALSE(!HasDecoderError(), "Not allowed to make more decoder calls after error!"); // If a data error occured, just ignore future data if (HasDataError()) return; // Pass the data along to the implementation WriteInternal(aBuffer, aCount); }
int CCircularBuffer::Write(byte *data, int offset, int count) { if (data == nullptr) return -1; if (count < 0) return -2; if (offset < 0) return -3; while (count > 0) { int r = WriteInternal(data, offset, count); offset += r; count -= r; } return count; }
int64_t StdStreamAdapter::Write(const uint8_t *cpbBuffer, int64_t cbBuffer) { if (m_oBackingStream.get() == nullptr) { // unavailable throw exceptions::RMSCryptoIOException( exceptions::RMSCryptoIOException::OperationUnavailable, "Operation unavailable!"); } // first lock object lock_guard<mutex> lock(*m_locker); try { WriteInternal(cpbBuffer, cbBuffer); } catch (exception& e) { throw e; } return cbBuffer; }
int RageFileObj::Write( const void *pBuffer, size_t iBytes ) { if( m_pWriteBuffer != NULL ) { /* If the file position has moved away from the write buffer, or the * incoming data won't fit in the buffer, flush. */ if( m_iWriteBufferPos+m_iWriteBufferUsed != m_iFilePos || m_iWriteBufferUsed + (int)iBytes > m_iWriteBufferSize ) { int iRet = EmptyWriteBuf(); if( iRet == -1 ) return iRet; } if( m_iWriteBufferUsed + (int)iBytes <= m_iWriteBufferSize ) { memcpy( m_pWriteBuffer+m_iWriteBufferUsed, pBuffer, iBytes ); m_iWriteBufferUsed += iBytes; m_iFilePos += iBytes; if( m_bCRC32Enabled ) CRC32( m_iCRC32, pBuffer, iBytes ); return iBytes; } /* We're writing a lot of data, and it won't fit in the buffer. We already * flushed above, so m_iWriteBufferUsed; fall through and write the block normally. */ ASSERT_M( m_iWriteBufferUsed == 0, ssprintf("%i", m_iWriteBufferUsed) ); } int iRet = WriteInternal( pBuffer, iBytes ); if( iRet != -1 ) { m_iFilePos += iRet; if( m_bCRC32Enabled ) CRC32( m_iCRC32, pBuffer, iBytes ); } return iRet; }
void Decoder::Write(const char* aBuffer, uint32_t aCount) { PROFILER_LABEL("ImageDecoder", "Write", js::ProfileEntry::Category::GRAPHICS); MOZ_ASSERT(aBuffer); MOZ_ASSERT(aCount > 0); // We're strict about decoder errors MOZ_ASSERT(!HasDecoderError(), "Not allowed to make more decoder calls after error!"); // Begin recording telemetry data. TimeStamp start = TimeStamp::Now(); mChunkCount++; // Keep track of the total number of bytes written. mBytesDecoded += aCount; // If a data error occured, just ignore future data. if (HasDataError()) { return; } if (IsMetadataDecode() && HasSize()) { // More data came in since we found the size. We have nothing to do here. return; } // Pass the data along to the implementation. WriteInternal(aBuffer, aCount); // Finish telemetry. mDecodeTime += (TimeStamp::Now() - start); }
nsresult Decoder::Write(const char* aBuffer, PRUint32 aCount) { // Pass the data along to the implementation return WriteInternal(aBuffer, aCount); }