Memory pool vectors (DVector) have been enormously simplified in code, and renamed to PoolVector
This commit is contained in:
@ -29,16 +29,16 @@
|
||||
#include "stream_peer.h"
|
||||
#include "io/marshalls.h"
|
||||
|
||||
Error StreamPeer::_put_data(const DVector<uint8_t>& p_data) {
|
||||
Error StreamPeer::_put_data(const PoolVector<uint8_t>& p_data) {
|
||||
|
||||
int len = p_data.size();
|
||||
if (len==0)
|
||||
return OK;
|
||||
DVector<uint8_t>::Read r = p_data.read();
|
||||
PoolVector<uint8_t>::Read r = p_data.read();
|
||||
return put_data(&r[0],len);
|
||||
}
|
||||
|
||||
Array StreamPeer::_put_partial_data(const DVector<uint8_t>& p_data) {
|
||||
Array StreamPeer::_put_partial_data(const PoolVector<uint8_t>& p_data) {
|
||||
|
||||
Array ret;
|
||||
|
||||
@ -49,7 +49,7 @@ Array StreamPeer::_put_partial_data(const DVector<uint8_t>& p_data) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
DVector<uint8_t>::Read r = p_data.read();
|
||||
PoolVector<uint8_t>::Read r = p_data.read();
|
||||
int sent;
|
||||
Error err = put_partial_data(&r[0],len,sent);
|
||||
|
||||
@ -66,18 +66,18 @@ Array StreamPeer::_get_data(int p_bytes) {
|
||||
|
||||
Array ret;
|
||||
|
||||
DVector<uint8_t> data;
|
||||
PoolVector<uint8_t> data;
|
||||
data.resize(p_bytes);
|
||||
if (data.size()!=p_bytes) {
|
||||
|
||||
ret.push_back(ERR_OUT_OF_MEMORY);
|
||||
ret.push_back(DVector<uint8_t>());
|
||||
ret.push_back(PoolVector<uint8_t>());
|
||||
return ret;
|
||||
}
|
||||
|
||||
DVector<uint8_t>::Write w = data.write();
|
||||
PoolVector<uint8_t>::Write w = data.write();
|
||||
Error err = get_data(&w[0],p_bytes);
|
||||
w = DVector<uint8_t>::Write();
|
||||
w = PoolVector<uint8_t>::Write();
|
||||
ret.push_back(err);
|
||||
ret.push_back(data);
|
||||
return ret;
|
||||
@ -88,19 +88,19 @@ Array StreamPeer::_get_partial_data(int p_bytes) {
|
||||
|
||||
Array ret;
|
||||
|
||||
DVector<uint8_t> data;
|
||||
PoolVector<uint8_t> data;
|
||||
data.resize(p_bytes);
|
||||
if (data.size()!=p_bytes) {
|
||||
|
||||
ret.push_back(ERR_OUT_OF_MEMORY);
|
||||
ret.push_back(DVector<uint8_t>());
|
||||
ret.push_back(PoolVector<uint8_t>());
|
||||
return ret;
|
||||
}
|
||||
|
||||
DVector<uint8_t>::Write w = data.write();
|
||||
PoolVector<uint8_t>::Write w = data.write();
|
||||
int received;
|
||||
Error err = get_partial_data(&w[0],p_bytes,received);
|
||||
w = DVector<uint8_t>::Write();
|
||||
w = PoolVector<uint8_t>::Write();
|
||||
|
||||
if (err!=OK) {
|
||||
data.resize(0);
|
||||
@ -454,7 +454,7 @@ Error StreamPeerBuffer::put_data(const uint8_t* p_data,int p_bytes) {
|
||||
|
||||
}
|
||||
|
||||
DVector<uint8_t>::Write w = data.write();
|
||||
PoolVector<uint8_t>::Write w = data.write();
|
||||
copymem(&w[pointer],p_data,p_bytes);
|
||||
|
||||
pointer+=p_bytes;
|
||||
@ -490,7 +490,7 @@ Error StreamPeerBuffer::get_partial_data(uint8_t* p_buffer, int p_bytes,int &r_r
|
||||
r_received=p_bytes;
|
||||
}
|
||||
|
||||
DVector<uint8_t>::Read r = data.read();
|
||||
PoolVector<uint8_t>::Read r = data.read();
|
||||
copymem(p_buffer,r.ptr(),r_received);
|
||||
}
|
||||
|
||||
@ -520,13 +520,13 @@ void StreamPeerBuffer::resize(int p_size){
|
||||
data.resize(p_size);
|
||||
}
|
||||
|
||||
void StreamPeerBuffer::set_data_array(const DVector<uint8_t> & p_data){
|
||||
void StreamPeerBuffer::set_data_array(const PoolVector<uint8_t> & p_data){
|
||||
|
||||
data=p_data;
|
||||
pointer=0;
|
||||
}
|
||||
|
||||
DVector<uint8_t> StreamPeerBuffer::get_data_array() const{
|
||||
PoolVector<uint8_t> StreamPeerBuffer::get_data_array() const{
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user