Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -254,11 +254,11 @@ case "$host_os" in darwin*) AC_SUBST(LDFLAGS_REEXPORT, ["-Wl,-reexport-lobjfw"]) AS_IF([test x"$objc_runtime" = x"Apple runtime"], [ - AC_SUBST(REEXPORT_LIBOBJC, ["-Wl,-reexport-lobjc"]) + AC_SUBST(REEXPORT_LIBOBJC, ["-Wl,-reexport-lobjc"]) tmp="-Xarch_x86_64 -Wl,-alias_list,mach_alias_list" AC_SUBST(MACH_ALIAS_LIST, $tmp) ]) ;; esac Index: src/OFDataArray+Hashing.m ================================================================== --- src/OFDataArray+Hashing.m +++ src/OFDataArray+Hashing.m @@ -26,11 +26,11 @@ @implementation OFDataArray (Hashing) - (OFString*)MD5Hash { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFMD5Hash *hash = [OFMD5Hash MD5Hash]; + OFMD5Hash *hash = [OFMD5Hash hash]; uint8_t *digest; char cString[OF_MD5_DIGEST_SIZE * 2]; size_t i; [hash updateWithBuffer: data @@ -55,11 +55,11 @@ } - (OFString*)SHA1Hash { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFMD5Hash *hash = [OFSHA1Hash SHA1Hash]; + OFMD5Hash *hash = [OFSHA1Hash hash]; uint8_t *digest; char cString[OF_SHA1_DIGEST_SIZE * 2]; size_t i; [hash updateWithBuffer: data Index: src/OFHash.h ================================================================== --- src/OFHash.h +++ src/OFHash.h @@ -26,10 +26,17 @@ #ifdef OF_HAVE_PROPERTIES @property (readonly, getter=isCalculated) BOOL calculated; #endif +/** + * \brief Creates a new hash. + * + * \return A new autoreleased OFHash + */ ++ hash; + /** * \brief Returns the digest size of the hash, in bytes. * * \return The digest size of the hash, in bytes */ @@ -43,14 +50,14 @@ + (size_t)blockSize; /** * \brief Adds a buffer to the hash to be calculated. * - * \param buf The buffer which should be included into the calculation. + * \param buffer The buffer which should be included into the calculation * \param length The length of the buffer */ -- (void)updateWithBuffer: (const char*)buf +- (void)updateWithBuffer: (const void*)buffer length: (size_t)length; /** * \brief Returns a buffer containing the hash. * Index: src/OFHash.m ================================================================== --- src/OFHash.m +++ src/OFHash.m @@ -19,10 +19,15 @@ #import "OFHash.h" #import "OFNotImplementedException.h" @implementation OFHash ++ hash +{ + return [[[self alloc] init] autorelease]; +} + + (size_t)digestSize { @throw [OFNotImplementedException exceptionWithClass: self selector: _cmd]; } @@ -31,11 +36,11 @@ { @throw [OFNotImplementedException exceptionWithClass: self selector: _cmd]; } -- (void)updateWithBuffer: (const char*)buffer +- (void)updateWithBuffer: (const void*)buffer length: (size_t)length { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } Index: src/OFMD5Hash.h ================================================================== --- src/OFMD5Hash.h +++ src/OFMD5Hash.h @@ -28,13 +28,6 @@ union { uint8_t u8[64]; uint32_t u32[16]; } in; } - -/** - * \brief Creates a new OFMD5Hash. - * - * \return A new autoreleased OFMD5Hash - */ -+ MD5Hash; @end Index: src/OFMD5Hash.m ================================================================== --- src/OFMD5Hash.m +++ src/OFMD5Hash.m @@ -117,15 +117,10 @@ buffer[2] += c; buffer[3] += d; } @implementation OFMD5Hash -+ MD5Hash -{ - return [[[self alloc] init] autorelease]; -} - + (size_t)digestSize { return 16; } @@ -144,14 +139,15 @@ buffer[3] = 0x10325476; return self; } -- (void)updateWithBuffer: (const char*)buffer_ +- (void)updateWithBuffer: (const void*)buffer__ length: (size_t)length { uint32_t t; + const char *buffer_ = buffer__; if (length == 0) return; if (calculated) Index: src/OFSHA1Hash.h ================================================================== --- src/OFSHA1Hash.h +++ src/OFSHA1Hash.h @@ -26,11 +26,6 @@ uint32_t state[5]; uint64_t count; char buffer[64]; uint8_t digest[OF_SHA1_DIGEST_SIZE]; } - -/** - * \return A new autoreleased SHA1 Hash - */ -+ SHA1Hash; @end Index: src/OFSHA1Hash.m ================================================================== --- src/OFSHA1Hash.m +++ src/OFSHA1Hash.m @@ -127,15 +127,10 @@ memcpy(&buffer[j], &buf[i], length - i); } @implementation OFSHA1Hash -+ SHA1Hash -{ - return [[[self alloc] init] autorelease]; -} - + (size_t)digestSize { return 20; } @@ -155,11 +150,11 @@ state[4] = 0xC3D2E1F0; return self; } -- (void)updateWithBuffer: (const char*)buffer_ +- (void)updateWithBuffer: (const void*)buffer_ length: (size_t)length { if (length == 0) return; Index: src/OFString+Hashing.m ================================================================== --- src/OFString+Hashing.m +++ src/OFString+Hashing.m @@ -25,11 +25,11 @@ @implementation OFString (Hashing) - (OFString*)MD5Hash { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFMD5Hash *hash = [OFMD5Hash MD5Hash]; + OFMD5Hash *hash = [OFMD5Hash hash]; uint8_t *digest; char ret[OF_MD5_DIGEST_SIZE * 2]; size_t i; [hash updateWithBuffer: [self UTF8String] @@ -54,11 +54,11 @@ } - (OFString*)SHA1Hash { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFMD5Hash *hash = [OFSHA1Hash SHA1Hash]; + OFMD5Hash *hash = [OFSHA1Hash hash]; uint8_t *digest; char ret[OF_SHA1_DIGEST_SIZE * 2]; size_t i; [hash updateWithBuffer: [self UTF8String] Index: tests/OFMD5HashTests.m ================================================================== --- tests/OFMD5HashTests.m +++ tests/OFMD5HashTests.m @@ -38,11 +38,11 @@ OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFMD5Hash *md5; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"rb"]; - TEST(@"+[MD5Hash]", (md5 = [OFMD5Hash MD5Hash])) + TEST(@"+[hash]", (md5 = [OFMD5Hash hash])) while (![f isAtEndOfStream]) { char buf[64]; size_t len = [f readIntoBuffer: buf length: 64]; Index: tests/OFSHA1HashTests.m ================================================================== --- tests/OFSHA1HashTests.m +++ tests/OFSHA1HashTests.m @@ -39,11 +39,11 @@ OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFSHA1Hash *sha1; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"rb"]; - TEST(@"+[SHA1Hash]", (sha1 = [OFSHA1Hash SHA1Hash])) + TEST(@"+[hash]", (sha1 = [OFSHA1Hash hash])) while (![f isAtEndOfStream]) { char buf[64]; size_t len = [f readIntoBuffer: buf length: 64];