3 int *p
= (int *)malloc(sizeof(int));
8 void __attribute((ownership_returns(malloc
))) *user_malloc(size_t);
9 void __attribute((ownership_takes(malloc
, 1))) *user_free(void *);
11 void __attribute((ownership_returns(malloc1
))) *user_malloc1(size_t);
12 void __attribute((ownership_takes(malloc1
, 1))) *user_free1(void *);
15 int *p
= (int *)user_malloc(sizeof(int));
28 realloc(p
, sizeof(long)); // warn
33 int *p
= user_malloc(10);
34 user_free1(p
); // warn
39 struct SimpleSmartPointer
{
42 explicit SimpleSmartPointer(T
*p
= 0) : ptr(p
) {}
43 ~SimpleSmartPointer() {
49 SimpleSmartPointer
<int> a((int *)malloc(4));
54 int *p
= (int *)operator new(0);
59 void test(NSUInteger dataLength
) {
61 NSData
*d
= [NSData dataWithBytesNoCopy
:p
62 length
:sizeof(int) freeWhenDone
:1];
63 // warn +dataWithBytesNoCopy:length:freeWhenDone: cannot take
64 // ownership of memory allocated by 'new'