1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_COMMON_MAC_OBJC_ZOMBIE_H_
6 #define CHROME_COMMON_MAC_OBJC_ZOMBIE_H_
8 #include "base/basictypes.h"
10 // You should think twice every single time you use anything from this
12 namespace ObjcEvilDoers
{
14 // Enable zombie object debugging. This implements a variant of Apple's
15 // NSZombieEnabled which can help expose use-after-free errors where messages
16 // are sent to freed Objective-C objects in production builds.
18 // Returns NO if it fails to enable.
20 // When |zombieAllObjects| is YES, all objects inheriting from
21 // NSObject become zombies on -dealloc. If NO, -shouldBecomeCrZombie
22 // is queried to determine whether to make the object a zombie.
24 // |zombieCount| controls how many zombies to store before freeing the
25 // oldest. Set to 0 to free objects immediately after making them
27 bool ZombieEnable(bool zombieAllObjects
, size_t zombieCount
);
32 } // namespace ObjcEvilDoers
34 #if defined(OS_MACOSX)
37 #import <Foundation/Foundation.h>
39 @interface
NSObject (CrZombie
)
40 - (BOOL
)shouldBecomeCrZombie
;
46 #endif // CHROME_COMMON_MAC_OBJC_ZOMBIE_H_