add support to encode/decode larger arrays

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34823 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2012-02-27 10:29:10 +00:00
parent 0c7763f7e1
commit b7a7b40179
4 changed files with 27 additions and 20 deletions

View file

@ -1,3 +1,10 @@
2012-02-27 Richard Frith-Macdonald <rfm@gnu.org>
* 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 <ewasylishen@gmail.com>
* Source/NSData.m: Various 64-bit compatibility fixes, mostly changing

View file

@ -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];

View file

@ -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;

View file

@ -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;