Code improvements in ser/deser code wrt passing data size (#39)
* Some code improvements in ser/deser code wrt passing data size to cycdeserbase class. Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com> * Move adjusting deserialisation limit in cycdeserbase to line where data pointer is moved. Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
This commit is contained in:
parent
a61a014a11
commit
c2c69ac032
1 changed files with 5 additions and 5 deletions
|
@ -32,10 +32,10 @@ cycser::cycser(std::vector<unsigned char> & dst_)
|
||||||
dst.push_back(0);
|
dst.push_back(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cycdeserbase::cycdeserbase(const char * data_, size_t lim_)
|
cycdeserbase::cycdeserbase(const char * data_, size_t size_)
|
||||||
: data(data_),
|
: data(data_),
|
||||||
pos(0),
|
pos(0),
|
||||||
lim(lim_),
|
lim(size_),
|
||||||
swap_bytes(false)
|
swap_bytes(false)
|
||||||
{
|
{
|
||||||
/* Get the endianness byte (skip unused first byte in data[0]) */
|
/* Get the endianness byte (skip unused first byte in data[0]) */
|
||||||
|
@ -46,17 +46,17 @@ cycdeserbase::cycdeserbase(const char * data_, size_t lim_)
|
||||||
|
|
||||||
/* Ignore representation options (data_[2] and data_[3]) */
|
/* Ignore representation options (data_[2] and data_[3]) */
|
||||||
data += 4;
|
data += 4;
|
||||||
|
lim -= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
cycdeser::cycdeser(const void * data_, size_t size_)
|
cycdeser::cycdeser(const void * data_, size_t size_)
|
||||||
: cycdeserbase(static_cast<const char *>(data_), size_ - 4)
|
: cycdeserbase(static_cast<const char *>(data_), size_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
cycprint::cycprint(char * buf_, size_t bufsize_, const void * data_, size_t size_)
|
cycprint::cycprint(char * buf_, size_t bufsize_, const void * data_, size_t size_)
|
||||||
: cycdeserbase(static_cast<const char *>(data_), size_ - 4),
|
: cycdeserbase(static_cast<const char *>(data_), size_),
|
||||||
buf(buf_),
|
buf(buf_),
|
||||||
bufsize(bufsize_)
|
bufsize(bufsize_)
|
||||||
{
|
{
|
||||||
static_cast<void>(size_);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue