Skip to content

Commit b3b7ed4

Browse files
authored
Merge pull request #2091 from aap-sc/aap-sc/leakage_fix
Get rid of leaking pointers in examples for custom extension
2 parents bfe100f + a191144 commit b3b7ed4

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

ci-tests/custom-csr.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct xdummycsr_t : public extension_t {
3737
}
3838
};
3939

40-
REGISTER_EXTENSION(dummycsr, []() { return new xdummycsr_t; })
40+
REGISTER_EXTENSION(dummycsr, []() { static xdummycsr_t ext; return &ext; })
4141

4242
// Copied from spike main.
4343
// TODO: This should really be provided in libriscv

ci-tests/test-customext.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct xslliuw_dummy_t : public extension_t {
4646
}
4747
};
4848

49-
REGISTER_EXTENSION(dummyslliuw, []() { return new xslliuw_dummy_t; })
49+
REGISTER_EXTENSION(dummyslliuw, []() { static xslliuw_dummy_t ext; return &ext; })
5050

5151
// Copied from spike main.
5252
// TODO: This should really be provided in libriscv

customext/cflush.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ class cflush_t : public extension_t
4040
}
4141
};
4242

43-
REGISTER_EXTENSION(cflush, []() { return new cflush_t; })
43+
REGISTER_EXTENSION(cflush, []() { static cflush_t ext; return &ext; })

customext/dummy_rocc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ class dummy_rocc_t : public rocc_t
4444
reg_t acc[num_acc];
4545
};
4646

47-
REGISTER_EXTENSION(dummy_rocc, []() { return new dummy_rocc_t; })
47+
REGISTER_EXTENSION(dummy_rocc, []() { static dummy_rocc_t ext; return &ext; })

0 commit comments

Comments
 (0)