| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/common/mac/objc_zombie.h" | 5 #import "chrome/common/mac/objc_zombie.h" |
| 6 | 6 |
| 7 #include <AvailabilityMacros.h> | 7 #include <AvailabilityMacros.h> |
| 8 | 8 |
| 9 #include <execinfo.h> | 9 #include <execinfo.h> |
| 10 #import <objc/runtime.h> | 10 #import <objc/runtime.h> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 // Deallocated objects are re-classed as |CrZombie|. No superclass | 29 // Deallocated objects are re-classed as |CrZombie|. No superclass |
| 30 // because then the class would have to override many/most of the | 30 // because then the class would have to override many/most of the |
| 31 // inherited methods (|NSObject| is like a category magnet!). | 31 // inherited methods (|NSObject| is like a category magnet!). |
| 32 // Without the __attribute__, clang's -Wobjc-root-class warns on the missing | 32 // Without the __attribute__, clang's -Wobjc-root-class warns on the missing |
| 33 // superclass. | 33 // superclass. |
| 34 // | 34 // |
| 35 // The version of clang that ships with Xcode 4.5 does not include this | 35 // The version of clang that ships with Xcode 4.5 does not include this |
| 36 // warning, so it is disabled on iOS. This may change in future Xcode | 36 // warning, so it is disabled on iOS. This may change in future Xcode |
| 37 // releases. | 37 // releases. |
| 38 #if !defined(OS_IOS) | 38 // TODO(justincohen): This is fixed in clang 4.2 in XCode 4.6. Remove this |
| 39 // once everyone is moved to XCode 4.6 b/7882496. |
| 40 #if !defined(OS_IOS) || \ |
| 41 (__clang_major__ > 4 || (__clang_major__ == 4 && __clang_minor__ >= 2)) |
| 39 __attribute__((objc_root_class)) | 42 __attribute__((objc_root_class)) |
| 40 #endif | 43 #endif |
| 41 @interface CrZombie { | 44 @interface CrZombie { |
| 42 Class isa; | 45 Class isa; |
| 43 } | 46 } |
| 44 @end | 47 @end |
| 45 | 48 |
| 46 // Objects with enough space are made into "fat" zombies, which | 49 // Objects with enough space are made into "fat" zombies, which |
| 47 // directly remember which class they were until reallocated. | 50 // directly remember which class they were until reallocated. |
| 48 @interface CrFatZombie : CrZombie { | 51 @interface CrFatZombie : CrZombie { |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 if (oldZombies) { | 431 if (oldZombies) { |
| 429 for (size_t i = 0; i < oldCount; ++i) { | 432 for (size_t i = 0; i < oldCount; ++i) { |
| 430 if (oldZombies[i].object) | 433 if (oldZombies[i].object) |
| 431 object_dispose(oldZombies[i].object); | 434 object_dispose(oldZombies[i].object); |
| 432 } | 435 } |
| 433 free(oldZombies); | 436 free(oldZombies); |
| 434 } | 437 } |
| 435 } | 438 } |
| 436 | 439 |
| 437 } // namespace ObjcEvilDoers | 440 } // namespace ObjcEvilDoers |
| OLD | NEW |