From d11b0a677363e59c819fcffe47ca37128901d13e Mon Sep 17 00:00:00 2001 From: Chris Bradley Date: Tue, 20 Feb 2024 17:25:14 +0000 Subject: [PATCH] Close FILE created in GribHandle, cleanup comments --- src/metkit/codes/GribHandle.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/metkit/codes/GribHandle.cc b/src/metkit/codes/GribHandle.cc index f766f01..cf8b82e 100644 --- a/src/metkit/codes/GribHandle.cc +++ b/src/metkit/codes/GribHandle.cc @@ -80,6 +80,8 @@ GribHandle::GribHandle(eckit::DataHandle& handle): CODES_CALL(err); ASSERT(h); handle_ = h; + + fclose(f); } GribHandle::GribHandle(eckit::DataHandle& handle, eckit::Offset offset): @@ -92,17 +94,15 @@ GribHandle::GribHandle(eckit::DataHandle& handle, eckit::Offset offset): FILE* f = handle.openf(); ASSERT(f); - fseek(f, offset, SEEK_SET); + handle.seek(offset); + h = codes_handle_new_from_file(0, f, PRODUCT_GRIB, &err); CODES_CALL(err); ASSERT(h); handle_ = h; - // XXX: Part of a workaround to sync handle and f on linux. - // XXX: This needs to be investigated further. - handle.seek(ftello(f)); - fclose(f); // XXX: The other constructor does not close the file, why do we? + fclose(f); } GribHandle::~GribHandle() noexcept(false) {