Skip to content

Commit

Permalink
Close FILE created in GribHandle, cleanup comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisspyB committed Feb 20, 2024
1 parent e02d9fb commit d11b0a6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/metkit/codes/GribHandle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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) {
Expand Down

0 comments on commit d11b0a6

Please sign in to comment.