• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: I think I am leaking! :)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I think I am leaking! :)


  • Subject: Re: I think I am leaking! :)
  • From: John Hörnkvist <email@hidden>
  • Date: Sun, 28 Oct 2001 02:31:40 +0100

On Sunday, October 28, 2001, at 02:43 AM, Andrew Platzer wrote:

For the NSHTTPURLHandle, that's more difficult. If this is for an application that you want to ship, please contact me and we can figure something out. I have to talk to the owner of the code about these problems.

This is rather easy actually; all you need to do is to give the old dealloc method another name and install your own dealloc method in its place, or just keep a pointer to the old dealloc implementation.

The idea is that you end up with something like this:

@implementation NSHTTPURLHandle(DeallocPatch)

static IMP NSHTTPURLHandle_dealloc=nil;

+ (void)install_patch
{
NSHTTPURLHandle_dealloc=[self instanceMethodForSelector:@selector(dealloc)];
struct objc_method *method;

if (method = class_getInstanceMethod(aClass, oldSelector))
{
method->method_imp = [self instanceMethodForSelector;@selector(my_dealloc)];
_objc_flush_caches([self class]); // From memory; there may be a documented way of doing this...
}
}

- (void)my_dealloc
{
NSHTTPURLHandle_dealloc(self,@selector(dealloc));
[super dealloc];
}
@end

Just remember to call install_patch, and you should be fine.

Warning: I haven't tested the above; I just typed it in.

Regards,
John Hornkvist
--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com


References: 
 >Re: I think I am leaking! :) (From: Andrew Platzer <email@hidden>)

  • Prev by Date: Re: Widget Repository?
  • Next by Date: Problems with NSDictionary's writeToFile"atomically: method
  • Previous by thread: Re: I think I am leaking! :)
  • Next by thread: Re: I think I am leaking! :)
  • Index(es):
    • Date
    • Thread