| 1 | |
| 2 | void test() { |
| 3 | int *p = (int *)malloc(sizeof(int)); |
| 4 | delete p; |
| 5 | } |
| 6 | |
| 7 | |
| 8 | void __attribute((ownership_returns(malloc))) *user_malloc(size_t); |
| 9 | |
| 10 | void test() { |
| 11 | int *p = (int *)user_malloc(sizeof(int)); |
| 12 | delete p; |
| 13 | } |
| 14 | |
| 15 | |
| 16 | void test() { |
| 17 | int *p = new int; |
| 18 | free(p); |
| 19 | } |
| 20 | |
| 21 | |
| 22 | void test() { |
| 23 | int *p = new int[1]; |
| 24 | realloc(p, sizeof(long)); |
| 25 | } |
| 26 | |
| 27 | |
| 28 | template <typename T> |
| 29 | struct SimpleSmartPointer { |
| 30 | T *ptr; |
| 31 | |
| 32 | explicit SimpleSmartPointer(T *p = 0) : ptr(p) {} |
| 33 | ~SimpleSmartPointer() { |
| 34 | delete ptr; |
| 35 | } |
| 36 | }; |
| 37 | |
| 38 | void test() { |
| 39 | SimpleSmartPointer<int> a((int *)malloc(4)); |
| 40 | } |
| 41 | |
| 42 | |
| 43 | void test() { |
| 44 | int *p = (int *)operator new(0); |
| 45 | delete[] p; |
| 46 | } |
| 47 | |
| 48 | |
| 49 | void test(NSUInteger dataLength) { |
| 50 | int *p = new int; |
| 51 | NSData *d = [NSData dataWithBytesNoCopy:p |
| 52 | length:sizeof(int) freeWhenDone:1]; |
| 53 | |
| 54 | |
| 55 | } |
| 56 | |
| 57 | |