Skip to content

Commit

Permalink
Merge commit 'be1c530a0c92701841fa6a427d4f6a53d299cdeb'
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen committed Apr 26, 2015
2 parents afdebe8 + be1c530 commit 5e63b5d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions subtree/rabit/include/dmlc/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,33 +300,33 @@ class istream : public std::basic_istream<char> {
// implementations of inline functions
template<typename T>
inline void Stream::Write(const std::vector<T> &vec) {
size_t sz = vec.size();
uint64_t sz = static_cast<uint64_t>(vec.size());
this->Write(&sz, sizeof(sz));
if (sz != 0) {
this->Write(&vec[0], sizeof(T) * sz);
}
}
template<typename T>
inline bool Stream::Read(std::vector<T> *out_vec) {
size_t sz;
uint64_t sz;
if (this->Read(&sz, sizeof(sz)) == 0) return false;
out_vec->resize(sz);
out_vec->resize(static_cast<size_t>(sz));
if (sz != 0) {
if (this->Read(&(*out_vec)[0], sizeof(T) * sz) == 0) return false;
}
return true;
}
inline void Stream::Write(const std::string &str) {
size_t sz = str.length();
uint64_t sz = static_cast<uint64_t>(str.length());
this->Write(&sz, sizeof(sz));
if (sz != 0) {
this->Write(&str[0], sizeof(char) * sz);
}
}
inline bool Stream::Read(std::string *out_str) {
size_t sz;
uint64_t sz;
if (this->Read(&sz, sizeof(sz)) == 0) return false;
out_str->resize(sz);
out_str->resize(static_cast<size_t>(sz));
if (sz != 0) {
if (this->Read(&(*out_str)[0], sizeof(char) * sz) == 0) {
return false;
Expand Down
1 change: 1 addition & 0 deletions subtree/rabit/include/rabit/rabit-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ inline void TrackerPrintf(const char *fmt, ...) {
va_start(args, fmt);
vsnprintf(&msg[0], kPrintBuffer, fmt, args);
va_end(args);
msg.resize(strlen(msg.c_str()));
TrackerPrint(msg);
}
#endif
Expand Down
8 changes: 4 additions & 4 deletions subtree/rabit/include/rabit/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ extern "C" {

#ifdef _MSC_VER
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long uint64_t;
typedef long int64_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
typedef __int64 int64_t;
#else
#include <inttypes.h>
#endif
Expand Down

0 comments on commit 5e63b5d

Please sign in to comment.