Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak in C API test #5303

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dali/c_api/c_api_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,7 @@ TEST(CApiTest, CheckpointingTest) {
auto handle2 = CreateCheckpointingTestPipe();
daliExternalContextCheckpoint restored_external_context{};
daliRestoreFromSerializedCheckpoint(&handle2, cpt, n, &restored_external_context);
free(cpt);
Copy link
Contributor

@mzient mzient Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more of a remark about the C API than this PR. It's generally not a good C API design when a function returns memory that is freed elsewhere, with generic C library calls. We should probably have a daliFree function.

EXPECT_EQ(restored_external_context.epoch_idx, mock_external_context.epoch_idx);
EXPECT_EQ(restored_external_context.iter, mock_external_context.iter);

Expand Down
Loading