From fed1683b9bb031041cc2bf113633cfd40c9faf46 Mon Sep 17 00:00:00 2001 From: tqchen Date: Sat, 25 Apr 2015 21:24:38 -0700 Subject: [PATCH] minor --- include/dmlc/io.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/dmlc/io.h b/include/dmlc/io.h index 8caf2a1f7..3db41c109 100644 --- a/include/dmlc/io.h +++ b/include/dmlc/io.h @@ -310,9 +310,10 @@ template inline bool Stream::Read(std::vector *out_vec) { uint64_t sz; if (this->Read(&sz, sizeof(sz)) == 0) return false; - out_vec->resize(static_cast(sz)); + size_t size = static_cast(sz); + out_vec->resize(size); if (sz != 0) { - if (this->Read(&(*out_vec)[0], sizeof(T) * sz) == 0) return false; + if (this->Read(&(*out_vec)[0], sizeof(T) * size) == 0) return false; } return true; } @@ -326,9 +327,10 @@ inline void Stream::Write(const std::string &str) { inline bool Stream::Read(std::string *out_str) { uint64_t sz; if (this->Read(&sz, sizeof(sz)) == 0) return false; - out_str->resize(static_cast(sz)); + size_t size = static_cast(sz); + out_str->resize(size); if (sz != 0) { - if (this->Read(&(*out_str)[0], sizeof(char) * sz) == 0) { + if (this->Read(&(*out_str)[0], sizeof(char) * size) == 0) { return false; } }