[libc][test] fix memory leak pt.2 (#122384)
[llvm-project.git] / lldb / test / API / lang / cpp / global_operators / main.cpp
blobc6dafd2958654eb9127b2b49d1510f630ce32da4
1 #include <new>
3 struct new_tag_t
5 };
6 new_tag_t new_tag;
8 struct Struct {
9 int value;
12 bool operator==(const Struct &a, const Struct &b) {
13 return a.value == b.value;
16 typedef char buf_t[sizeof(Struct)];
17 buf_t global_new_buf, tagged_new_buf;
19 // This overrides global operator new
20 // This function and the following does not actually allocate memory. We are merely
21 // trying to make sure it is getting called.
22 void *
23 operator new(std::size_t count)
25 return &global_new_buf;
28 // A custom allocator
29 void *
30 operator new(std::size_t count, const new_tag_t &)
32 return &tagged_new_buf;
35 int main() {
36 Struct s1, s2, s3;
37 s1.value = 3;
38 s2.value = 5;
39 s3.value = 3;
40 return 0; // break here