51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
}
static void __attribute__((constructor))
init(void)
{
Class NSAutoreleasePool = objc_getClass("NSAutoreleasePool");
Class NSObject = objc_getClass("NSObject");
Method alloc_method;
Method addObject_method;
Method autorelease_method;
if (NSAutoreleasePool == Nil || NSObject == Nil)
return;
alloc_method = class_getClassMethod(NSAutoreleasePool,
@selector(alloc));
addObject_method = class_getClassMethod(NSAutoreleasePool,
@selector(addObject:));
autorelease_method = class_getInstanceMethod(NSObject,
@selector(autorelease));
if (alloc_method == NULL || addObject_method == NULL ||
autorelease_method == NULL)
return;
class_replaceMethod(NSAutoreleasePool->isa, @selector(alloc),
(IMP)alloc, method_getTypeEncoding(alloc_method));
class_replaceMethod(NSAutoreleasePool->isa, @selector(addObject:),
(IMP)addObject, method_getTypeEncoding(addObject_method));
class_replaceMethod(NSObject, @selector(autorelease),
(IMP)autorelease, method_getTypeEncoding(autorelease_method));
}
|
|
|
|
|
|
|
|
|
|
|
|
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
}
static void __attribute__((constructor))
init(void)
{
Class NSAutoreleasePool = objc_getClass("NSAutoreleasePool");
Class NSObject = objc_getClass("NSObject");
Method allocMethod;
Method addObjectMethod;
Method autoreleaseMethod;
if (NSAutoreleasePool == Nil || NSObject == Nil)
return;
allocMethod = class_getClassMethod(NSAutoreleasePool,
@selector(alloc));
addObjectMethod = class_getClassMethod(NSAutoreleasePool,
@selector(addObject:));
autoreleaseMethod = class_getInstanceMethod(NSObject,
@selector(autorelease));
if (allocMethod == NULL || addObjectMethod == NULL ||
autoreleaseMethod == NULL)
return;
class_replaceMethod(NSAutoreleasePool->isa, @selector(alloc),
(IMP)alloc, method_getTypeEncoding(allocMethod));
class_replaceMethod(NSAutoreleasePool->isa, @selector(addObject:),
(IMP)addObject, method_getTypeEncoding(addObjectMethod));
class_replaceMethod(NSObject, @selector(autorelease),
(IMP)autorelease, method_getTypeEncoding(autoreleaseMethod));
}
|