Skip to content

Commit

Permalink
Bugfix in message packing of vectors and maps
Browse files Browse the repository at this point in the history
  • Loading branch information
sm0svx committed Mar 3, 2017
1 parent 2f52294 commit f1913af
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/async/core/AsyncMsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,13 @@ class MsgPacker<std::vector<I> >
}
static size_t packedSize(const std::vector<I>& vec)
{
return sizeof(uint16_t) + MsgPacker<I>::packedSize(vec[0]) * vec.size();
size_t size = sizeof(uint16_t);
for (typename std::vector<I>::const_iterator it = vec.begin();
it != vec.end(); ++it)
{
size += MsgPacker<I>::packedSize(*it);
}
return size;
}
static bool unpack(std::istream& is, std::vector<I>& vec)
{
Expand Down Expand Up @@ -404,9 +410,14 @@ class MsgPacker<std::map<Tag,Value> >
}
static size_t packedSize(const std::map<Tag, Value>& m)
{
return sizeof(uint16_t) +
m.size() * (MsgPacker<Tag>::packedSize((*m.begin()).first) +
MsgPacker<Value>::packedSize((*m.begin()).second));
size_t size = sizeof(uint16_t);
for (typename std::map<Tag, Value>::const_iterator it = m.begin();
it != m.end(); ++it)
{
size += (MsgPacker<Tag>::packedSize((*it).first) +
MsgPacker<Value>::packedSize((*it).second));
}
return size;
}
static bool unpack(std::istream& is, std::map<Tag,Value>& m)
{
Expand Down

0 comments on commit f1913af

Please sign in to comment.