MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / Get

Method Get

cpp/src/platform/Stream.cpp:90–126  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Remove data from the buffer -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

88// Remove data from the buffer
89//-----------------------------------------------------------------------------
90bool Stream::Get
91(
92 uint8* _buffer,
93 uint32 _size
94)
95{
96 if( m_dataSize < _size )
97 {
98 // There is not enough data in the buffer to fulfill the request
99 Log::Write( LogLevel_Error, "ERROR: Not enough data in stream buffer");
100 return false;
101 }
102
103 m_mutex->Lock();
104 if( (m_tail + _size) > m_bufferSize )
105 {
106 // We will have to wrap around
107 uint32 block1 = m_bufferSize - m_tail;
108 uint32 block2 = _size - block1;
109
110 memcpy( _buffer, &m_buffer[m_tail], block1 );
111 memcpy( &_buffer[block1], m_buffer, block2 );
112 m_tail = block2;
113 }
114 else
115 {
116 // Requested data is in a contiguous block
117 memcpy( _buffer, &m_buffer[m_tail], _size );
118 m_tail += _size;
119 }
120
121 LogData( _buffer, _size, " Read (buffer->application): ");
122
123 m_dataSize -= _size;
124 m_mutex->Unlock();
125 return true;
126}
127
128//-----------------------------------------------------------------------------
129// <Stream::Put>

Callers

nothing calls this directly

Calls 3

WriteFunction · 0.85
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected