File tree Expand file tree Collapse file tree 3 files changed +10
-32
lines changed Expand file tree Collapse file tree 3 files changed +10
-32
lines changed Original file line number Diff line number Diff line change @@ -67,36 +67,6 @@ - (id)objectAtIndex:(NSUInteger)index {
6767 return value;
6868}
6969
70- - (NSUInteger )countByEnumeratingWithState : (NSFastEnumerationState *)state objects : (id __unsafe_unretained _Nullable [_Nonnull])buffer count : (NSUInteger )len {
71- if (state->state == 0 ) { // uninitialized
72- state->state = 1 ;
73- void * selfPtr = (__bridge void *)self;
74- state->mutationsPtr = (unsigned long *)selfPtr;
75- state->extra [0 ] = 0 ; // current index
76- NSUInteger cnt = [self count ];
77- state->extra [1 ] = cnt;
78- }
79-
80- NSUInteger currentIndex = state->extra [0 ];
81- unsigned long length = state->extra [1 ];
82- NSUInteger count = 0 ;
83- state->itemsPtr = buffer;
84-
85- @autoreleasepool {
86- while (count < len && currentIndex < length) {
87- id obj = [self objectAtIndex: currentIndex];
88- CFBridgingRetain (obj);
89- *buffer++ = obj;
90- currentIndex++;
91- count++;
92- }
93- }
94-
95- state->extra [0 ] = currentIndex;
96-
97- return count;
98- }
99-
10070- (void )dealloc {
10171 self->cache_ ->Instances .erase (self);
10272 Local<Value> value = self->object_ ->Get (self->isolate_ );
@@ -106,6 +76,9 @@ - (void)dealloc {
10676 delete wrapper;
10777 }
10878 self->object_ ->Reset ();
79+ self->isolate_ = nullptr ;
80+ self->cache_ = nullptr ;
81+ self->object_ = nullptr ;
10982 [super dealloc ];
11083}
11184
Original file line number Diff line number Diff line change @@ -234,12 +234,12 @@ - (NSEnumerator*)keyEnumerator {
234234 Local<Value> obj = self->object_ ->Get (self->isolate_ );
235235
236236 if (obj->IsMap ()) {
237- self->enumerator_ = [[DictionaryAdapterMapKeysEnumerator alloc ] initWithMap: self ->object_ isolate: self ->isolate_ cache: self ->cache_];
237+ self->enumerator_ = [[[ DictionaryAdapterMapKeysEnumerator alloc ] initWithMap: self ->object_ isolate: self ->isolate_ cache: self ->cache_] autorelease ];
238238
239239 return self->enumerator_ ;
240240 }
241241
242- self->enumerator_ = [[DictionaryAdapterObjectKeysEnumerator alloc ] initWithProperties: self ->object_ isolate: self ->isolate_ cache: self ->cache_];
242+ self->enumerator_ = [[[ DictionaryAdapterObjectKeysEnumerator alloc ] initWithProperties: self ->object_ isolate: self ->isolate_ cache: self ->cache_] autorelease ];
243243
244244 return self->enumerator_ ;
245245}
@@ -261,6 +261,8 @@ - (void)dealloc {
261261 // CFAutorelease(self->enumerator_);
262262 self->enumerator_ = nullptr ;
263263 }
264+ self->cache_ = nullptr ;
265+ self->object_ = nullptr ;
264266
265267 [super dealloc ];
266268}
Original file line number Diff line number Diff line change @@ -66,6 +66,9 @@ - (void)dealloc {
6666 delete wrapper;
6767 }
6868 self->object_ ->Reset ();
69+ self->isolate_ = nullptr ;
70+ self->cache_ = nullptr ;
71+ self->object_ = nullptr ;
6972 [super dealloc ];
7073}
7174
You can’t perform that action at this time.
0 commit comments