Skip to content

Commit 06b0db6

Browse files
authored
[SYCL][E2E] fix one test leak (#12037)
Because SYCL will throw an exception, malloced `ptr` will never freed, which is a leak. Use std::vector to make it freed automatically.
1 parent f715119 commit 06b0db6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sycl/test-e2e/Basic/nested_queue_submit.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33

44
#include <cstdlib>
55
#include <sycl/sycl.hpp>
6+
#include <vector>
67

78
void nestedSubmit() {
89
uint32_t n = 1024;
9-
float *ptr = (float *)malloc(n * sizeof(float));
10+
std::vector<float> array(n);
1011
sycl::queue q{};
1112
{
12-
sycl::buffer<float> buf(ptr, sycl::range<1>{n});
13+
sycl::buffer<float> buf(array.data(), sycl::range<1>{n});
1314
q.submit([&](sycl::handler &h) {
1415
auto acc = buf.get_access<sycl::access::mode::write>(h);
1516
q.parallel_for<class zero>(sycl::range<1>{n},
1617
[=](sycl::id<1> i) { acc[i] = float(0.0); });
1718
});
1819
}
19-
free(ptr);
2020
}
2121

2222
int main() {

0 commit comments

Comments
 (0)