Commit 24f1f9cd authored by Guolin Ke's avatar Guolin Ke
Browse files

fixed some IO bugs

parent c96ae6af
...@@ -34,6 +34,9 @@ public: ...@@ -34,6 +34,9 @@ public:
#else #else
file = fopen(filename, "r"); file = fopen(filename, "r");
#endif #endif
if (file == NULL) {
Log::Fatal("failed to open file %s", filename);
}
std::stringstream str_buf; std::stringstream str_buf;
int read_c = -1; int read_c = -1;
read_c = fgetc(file); read_c = fgetc(file);
......
...@@ -310,7 +310,7 @@ void Metadata::LoadFromMemory(const void* memory) { ...@@ -310,7 +310,7 @@ void Metadata::LoadFromMemory(const void* memory) {
if (label_ != nullptr) { delete[] label_; } if (label_ != nullptr) { delete[] label_; }
label_ = new float[num_data_]; label_ = new float[num_data_];
std::memcpy(label_, mem_ptr, sizeof(float)*num_data_); std::memcpy(label_, mem_ptr, sizeof(float)*num_data_);
mem_ptr += sizeof(float)*num_weights_; mem_ptr += sizeof(float)*num_data_;
if (num_weights_ > 0) { if (num_weights_ > 0) {
if (weights_ != nullptr) { delete[] weights_; } if (weights_ != nullptr) { delete[] weights_; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment