diff --git a/ChangeLog b/ChangeLog index 4af54a6f0..dba84085d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-02-27 Richard Frith-Macdonald + + * Source/NSArchiver.m: + * Source/NSUnarchiver.m: + Alter to support encoding and decoding arrays with NSUInteger counts + (ie more than 2^32 objects if on a 64bit system). + 2012-02-26 Eric Wasylishen * Source/NSData.m: Various 64-bit compatibility fixes, mostly changing diff --git a/Source/NSArchiver.m b/Source/NSArchiver.m index c2109f79a..b74a56f55 100644 --- a/Source/NSArchiver.m +++ b/Source/NSArchiver.m @@ -254,9 +254,9 @@ static Class NSMutableDataMallocClass; count: (NSUInteger)count at: (const void*)buf { - unsigned c = count; - unsigned i; - unsigned offset = 0; + NSUInteger c = count; + NSUInteger i; + NSUInteger offset = 0; unsigned size = objc_sizeof_type(type); uchar info; @@ -287,7 +287,7 @@ static Class NSMutableDataMallocClass; if (_initialPass == NO) { (*_tagImp)(_dst, tagSel, _GSC_ARY_B); - (*_serImp)(_dst, serSel, &c, @encode(unsigned), nil); + (*_serImp)(_dst, serSel, &c, @encode(NSUInteger), nil); } for (i = 0; i < c; i++) { @@ -298,7 +298,7 @@ static Class NSMutableDataMallocClass; else if (_initialPass == NO) { (*_tagImp)(_dst, tagSel, _GSC_ARY_B); - (*_serImp)(_dst, serSel, &c, @encode(unsigned), nil); + (*_serImp)(_dst, serSel, &c, @encode(NSUInteger), nil); (*_tagImp)(_dst, tagSel, info); for (i = 0; i < c; i++) @@ -320,7 +320,7 @@ static Class NSMutableDataMallocClass; case _C_ARY_B: { - unsigned count = atoi(++type); + NSUInteger count = atoll(++type); while (isdigit(*type)) { @@ -734,9 +734,9 @@ static Class NSMutableDataMallocClass; - (void) encodeDataObject: (NSData*)anObject { - unsigned l = [anObject length]; + NSUInteger l = [anObject length]; - (*_eValImp)(self, eValSel, @encode(unsigned int), &l); + (*_eValImp)(self, eValSel, @encode(NSUInteger), &l); if (l) { const void *b = [anObject bytes]; diff --git a/Source/NSData.m b/Source/NSData.m index 74dafaa28..166181159 100644 --- a/Source/NSData.m +++ b/Source/NSData.m @@ -1870,7 +1870,7 @@ failure: - (void) encodeWithCoder: (NSCoder*)aCoder { - NSUInteger length = [self length]; + unsigned length = [self length]; void *bytes = [self mutableBytes]; if ([aCoder allowsKeyedCoding]) @@ -1881,7 +1881,7 @@ failure: } else { - [aCoder encodeValueOfObjCType: @encode(NSUInteger) + [aCoder encodeValueOfObjCType: @encode(unsigned) at: &length]; if (length) { @@ -1917,9 +1917,9 @@ failure: } else { - NSUInteger l; + unsigned l; - [aCoder decodeValueOfObjCType: @encode(NSUInteger) at: &l]; + [aCoder decodeValueOfObjCType: @encode(unsigned) at: &l]; if (l) { void *b; diff --git a/Source/NSUnarchiver.m b/Source/NSUnarchiver.m index 8d213c077..78742eeca 100644 --- a/Source/NSUnarchiver.m +++ b/Source/NSUnarchiver.m @@ -529,14 +529,14 @@ static Class NSDataMallocClass; count: (NSUInteger)expected at: (void*)buf { - unsigned int i; - int offset = 0; - unsigned int size = (unsigned int)objc_sizeof_type(type); + NSUInteger i; + NSUInteger offset = 0; + NSUInteger size = (unsigned int)objc_sizeof_type(type); unsigned char info; - unsigned count; + NSUInteger count; (*tagImp)(src, tagSel, &info, 0, &cursor); - (*desImp)(src, desSel, &count, @encode(unsigned), &cursor, nil); + (*desImp)(src, desSel, &count, @encode(NSUInteger), &cursor, nil); if (info != _GSC_ARY_B) { [NSException raise: NSInternalInconsistencyException @@ -545,7 +545,7 @@ static Class NSDataMallocClass; if (count != expected) { [NSException raise: NSInternalInconsistencyException - format: @"expected array count %u and got %u", + format: @"expected array count %"PRIuPTR" and got %"PRIuPTR, expected, count]; } @@ -1219,9 +1219,9 @@ static Class NSDataMallocClass; - (NSData*) decodeDataObject { - unsigned l; + NSUInteger l; - (*dValImp)(self, dValSel, @encode(unsigned int), &l); + (*dValImp)(self, dValSel, @encode(NSUInteger), &l); if (l) { unsigned char c;