Fixed memory leaks in xfpga error tests.
@@ -76,6 +76,12 @@ class error_c_mock_p
}
virtual void TearDown() override {
+ if (fake_fme_token_.errors) {
+ free_error_list(fake_fme_token_.errors);
+ }
+ if (fake_port_token_.errors) {
+ free_error_list(fake_port_token_.errors);
+ }
if (filter_) {
EXPECT_EQ(fpgaDestroyProperties(&filter_), FPGA_OK);
filter_ = nullptr;
@@ -84,6 +90,14 @@ class error_c_mock_p
system_->finalize();
}
+ void free_error_list(struct error_list *p) {
+ while (p) {
+ struct error_list *q = p->next;
+ free(p);
+ p = q;
+ }
+ }
+
fpga_properties filter_;
std::string tmpsysfs_;
test_platform platform_;
@@ -431,6 +445,8 @@ TEST_P(error_c_mock_p, error_06) {
}
}
+ free_error_list(fake_fme_token_.errors);
+
// set error list to null
fake_fme_token_.errors = nullptr;
EXPECT_EQ(FPGA_NOT_FOUND, xfpga_fpgaClearError(t, 0));
