Merge pull request #27347 from ANSHUMAN87:allocation-comments

PiperOrigin-RevId: 295238468
Change-Id: Ie60e320367d97030fb8b0aa8d2a884606ea57b51
This commit is contained in:
TensorFlower Gardener 2020-02-14 15:24:19 -08:00
commit dbc48cab35

View File

@ -34,15 +34,12 @@ namespace tflite {
FileCopyAllocation::FileCopyAllocation(const char* filename,
ErrorReporter* error_reporter)
: Allocation(error_reporter, Allocation::Type::kFileCopy) {
// Obtain the file size, using an alternative method that is does not
// require fstat for more compatibility.
// Obtain the file size using fstat, or report an error if that fails.
std::unique_ptr<FILE, decltype(&fclose)> file(fopen(filename, "rb"), fclose);
if (!file) {
error_reporter_->Report("Could not open '%s'.", filename);
return;
}
// TODO(ahentz): Why did you think using fseek here was better for finding
// the size?
struct stat sb;
// support usage of msvc's posix-like fileno symbol