Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: chrome/browser/cocoa/objc_zombie.mm

Issue 2857015: Clang/mac: Get unit_tests built. (Closed)
Patch Set: rebase Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/browser/cocoa/objc_zombie.h" 5 #import "chrome/browser/cocoa/objc_zombie.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <mach-o/dyld.h> 8 #include <mach-o/dyld.h>
9 #include <mach-o/nlist.h> 9 #include <mach-o/nlist.h>
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 nl[0].n_type == N_UNDF || nl[1].n_type == N_UNDF) 93 nl[0].n_type == N_UNDF || nl[1].n_type == N_UNDF)
94 return NULL; 94 return NULL;
95 95
96 return (DestructFn*)((char*)&class_addIvar - nl[1].n_value + nl[0].n_value); 96 return (DestructFn*)((char*)&class_addIvar - nl[1].n_value + nl[0].n_value);
97 } 97 }
98 98
99 // Replacement |-dealloc| which turns objects into zombies and places 99 // Replacement |-dealloc| which turns objects into zombies and places
100 // them into |g_zombies| to be freed later. 100 // them into |g_zombies| to be freed later.
101 void ZombieDealloc(id self, SEL _cmd) { 101 void ZombieDealloc(id self, SEL _cmd) {
102 // This code should only be called when it is implementing |-dealloc|. 102 // This code should only be called when it is implementing |-dealloc|.
103 DCHECK_EQ(_cmd, @selector(dealloc)); 103 //DCHECK_EQ(_cmd, @selector(dealloc)); // clang
104 104
105 // Use the original |-dealloc| if the object doesn't wish to be 105 // Use the original |-dealloc| if the object doesn't wish to be
106 // zombied. 106 // zombied.
107 if (!g_zombieAllObjects && ![self shouldBecomeCrZombie]) { 107 if (!g_zombieAllObjects && ![self shouldBecomeCrZombie]) {
108 g_originalDeallocIMP(self, _cmd); 108 g_originalDeallocIMP(self, _cmd);
109 return; 109 return;
110 } 110 }
111 111
112 // Use the original |-dealloc| if |object_cxxDestruct| was never 112 // Use the original |-dealloc| if |object_cxxDestruct| was never
113 // initialized, because otherwise C++ destructors won't be called. 113 // initialized, because otherwise C++ destructors won't be called.
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 if (oldZombies) { 405 if (oldZombies) {
406 for (size_t i = 0; i < oldCount; ++i) { 406 for (size_t i = 0; i < oldCount; ++i) {
407 if (oldZombies[i].object) 407 if (oldZombies[i].object)
408 free(oldZombies[i].object); 408 free(oldZombies[i].object);
409 } 409 }
410 free(oldZombies); 410 free(oldZombies);
411 } 411 }
412 } 412 }
413 413
414 } // namespace ObjcEvilDoers 414 } // namespace ObjcEvilDoers
OLDNEW
« no previous file with comments | « chrome/browser/autofill/form_structure_unittest.cc ('k') | chrome/browser/importer/firefox_importer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698