now that I added a auto release pool it crashes later on. but it doesn't have to do with MD5 anymore it has to do with the hexdump of SSCrypto.
0   libSystem.B.dylib                 0xffff07c7 __memcpy + 39
1 libobjc.A.dylib 0x9347c13e fixupSelectorsInMethodList + 99 2 libobjc.A.dylib 0x9347d426 _class_getMethodNoSuper + 150 3 libobjc.A.dylib 0x9347355e _class_lookupMethodAndLoadCache + 182
4   libobjc.A.dylib                   0x93483736 objc_msgSend + 102
5 libobjc.A.dylib 0x934734f9 _class_lookupMethodAndLoadCache + 81
6   libobjc.A.dylib                   0x93483736 objc_msgSend + 102
7 com.apple.CoreFoundation 0x9364a241 __CFStringChangeSizeMultiple + 1985 8 com.apple.CoreFoundation 0x9364dfc8 __CFStringCheckAndReplace + 280 9 com.apple.Foundation 0x94d7fde4 -[NSCFString appendString:] + 68 10 com.septicus.SSCrypto 0x20001243 -[NSData(HexDump) hexval] + 174
I'll try a few more things and see if that fixes it.

On Nov 4, 2008, at 7:56 AM, Roland King wrote:

does SSCrypto follow a different pattern from normal Cocoa objects? It's being created with alloc/init and that, for cocoa objects, gives it a retain count of 1, you own it, you have to release it.

SSCrypto *crypto = [[SSCrypto alloc] init];

I note also that the examples on the SSCrypto site show the alloc/ init + release pattern.


On Nov 4, 2008, at 9:48 PM, Alex Heinz wrote:

The SSCrypto object doesn't need to be released; it isn't being retained, and doesn't leave the scope of the function. It will be deallocated when control leaves the function.

Alex

On Nov 4, 2008, at 12:09 AM, Roland King wrote:

well no that would leak since then the crypto object wouldn't get released. Also, I don't have the documentation for SSCrypto but I'd have thought whatever the digest returns is already autoreleased, so releasing it again would be wrong.

Question is how are you calling this? Is there an autorelease pool set up somewhere which is actually getting purged? All autorelease is doing is sticking it on the autorelease pool, if nothing cleans up the pool, it'll just hang onto them forever.

What crash are you getting, are you getting out of memory or are you getting a crash because you're accessing an already freed object or freeing it twice?

Alex Heinz wrote:

You probably want [[[crypto digest:@"MD5"] hexval] autorelease]. This will add the NSString object to the autorelease pool, instead of the SSCrypto object, as you are doing now.

HTH,
Alex

On Nov 3, 2008, at 9:05 PM, Mr. Gecko wrote:

Hello I am trying to MD5 a whole bunch of strings and I choose SSCrypto for it, but for some reason, it crashes because of memory. I know it has to do with releasing, I haven't found much details on when to use release and autorelease; so this is a huge task for me to find out.
Here is my method I have made.
- (NSString *)md5:(NSString *)MD5 {
SSCrypto *crypto = [[SSCrypto alloc] init];
[crypto setClearTextWithString:MD5];

return [[[crypto autorelease] digest:@"MD5"] hexval];
}
if you could point out what I am doing wrong, I would be great full.

Thanks,
Mr. Gecko
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/aheinz2%40johnshopkins.edu

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org

This email sent to [EMAIL PROTECTED]



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to