Squashed 'subtree/rabit/' changes from c679671..82ca10a
82ca10a better handling at msvc 6601939 Merge pull request #12 from zjf/patch-2 df8f917 Update rabit-inl.h c60b284 resize during tracker print git-subtree-dir: subtree/rabit git-subtree-split: 82ca10acb643f0471c0f35687d1bfefd5d23deae
This commit is contained in:
parent
44fd329b02
commit
be1c530a0c
@ -300,7 +300,7 @@ 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);
|
||||
@ -308,25 +308,25 @@ inline void Stream::Write(const std::vector<T> &vec) {
|
||||
}
|
||||
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;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user