Summary: NSObject.init has no summary yet isn't recognised as allocating memory. This breaks ownership tracking. Reviewed By: jvillard Differential Revision: D10852627 fbshipit-source-id: 95e016c84master
parent
b0b8459c3a
commit
342bfb418a
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
#import <Foundation/NSObject.h>
|
||||||
|
#import <mutex>
|
||||||
|
|
||||||
|
@interface Ctor : NSObject
|
||||||
|
- (instancetype)init;
|
||||||
|
- (void)write:(int)data;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation Ctor {
|
||||||
|
std::mutex _mutex;
|
||||||
|
int _data;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
if (!(self = [super init])) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = _data;
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)write:(int)data {
|
||||||
|
_mutex.lock();
|
||||||
|
_data = data;
|
||||||
|
_mutex.unlock();
|
||||||
|
}
|
||||||
|
@end
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
#import "Ctor.mm"
|
||||||
|
#import <mutex>
|
||||||
|
|
||||||
|
@interface CtorInherit : Ctor
|
||||||
|
- (instancetype)init;
|
||||||
|
- (void)writeZero;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation CtorInherit
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
if (!(self = [super init])) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)writeZero {
|
||||||
|
[self write:0];
|
||||||
|
}
|
||||||
|
@end
|
Loading…
Reference in new issue