You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I have not misunderstood, the _used member in Poco::Buffer should contains the number of 'valid' data into the buffer.
But, if so, I have some doubts.
In some situation, it has the same meaning of 'capacity'...
For example, in the constructor:
Poco::Buffer<UINT8> _buffer(100); // _used is initialized to 100
bool is_empty = _buffer.empty(); // Return FALSE!
or using the clear() method:
Poco::Buffer<UINT8> _buffer(100);
_buffer.append(_data);
_buffer.clear(); // _used is not cleared
bool is_empty = _buffer.empty(); // Return FALSE!
Is this the desired behavior?
Of course I could have a buffer with all "valid" '0' but, in this case I will use the ctor:
Buffer(T* pMem, std::size_t length)
where _used is correctly valorized.
Daniele.
The text was updated successfully, but these errors were encountered:
When empty() is true, it means the size of used data in buffer is zero. _used is the valid (used) size, see Buffer::size(). Calling clear() zeroes the used memory but does not empty the buffer. There may be a difference between used and capacity because, after the buffer is shrunk to smaller capacity, unused memory is not deallocated, see resize() and setCapacity()
Hi Alex,
thanks for the reply.
I change my code from my_buffer.clear() to my_buffer.resize(0) to 'destroy' (or 'invalidate') the buffer, I don't have found another way to do it 😄
Hi,
If I have not misunderstood, the _used member in Poco::Buffer should contains the number of 'valid' data into the buffer.
But, if so, I have some doubts.
In some situation, it has the same meaning of 'capacity'...
For example, in the constructor:
or using the clear() method:
Is this the desired behavior?
Of course I could have a buffer with all "valid" '0' but, in this case I will use the ctor:
where _used is correctly valorized.
Daniele.
The text was updated successfully, but these errors were encountered: