Bundle AbstractItem::Serialize() const {
Bundle b;
- struct tm* timeinfo;
+ struct tm timeinfo;
char buf[80] = {0,};
if (impl_->uid_ == 0)
b.Add(ABSTRACT_ITEM_UID_KEY, to_string(impl_->uid_));
b.Add(ABSTRACT_ITEM_TAG_KEY, impl_->tag_);
- timeinfo = localtime(&impl_->time_);
- strftime (buf, sizeof(buf), "%s", timeinfo);
+ localtime_r(&impl_->time_, &timeinfo);
+ strftime (buf, sizeof(buf), "%s", &timeinfo);
b.Add(ABSTRACT_ITEM_TIME_KEY, string(buf));
if (!impl_->can_receive_.empty())
Bundle TimeItem::Serialize() const {
Bundle b;
- struct tm* timeinfo;
+ struct tm timeinfo;
char buf[80] = {0,};
b = AbstractItem::Serialize();
//timt_t to tm
- timeinfo = localtime(&impl_->time_);
+ localtime_r(&impl_->time_, &timeinfo);
//tm to str
- strftime (buf, sizeof(buf), "%s", timeinfo);
+ strftime (buf, sizeof(buf), "%s", &timeinfo);
b.Add(TIME_KEY, std::string(buf));
return b;