mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 08:41:03 +00:00
Fixes from Frith-MacDonald.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2701 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
328c20784a
commit
78524cf7a9
31 changed files with 2483 additions and 406 deletions
|
@ -257,6 +257,12 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
|||
#endif
|
||||
}
|
||||
|
||||
+ (id) dataWithData: (NSData*)data
|
||||
{
|
||||
return [[[NSDataMalloc alloc] initWithBytes: [data bytes]
|
||||
length: [data length]] autorelease];
|
||||
}
|
||||
|
||||
- (id) initWithBytes: (const void*)bytes
|
||||
length: (unsigned int)length
|
||||
{
|
||||
|
@ -317,7 +323,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
|||
{
|
||||
dest[j++] = num2char((src[i]>>4) & 0x0f);
|
||||
dest[j] = num2char(src[i] & 0x0f);
|
||||
if((i&0x3) == 3)
|
||||
if((i&0x3) == 3 && i != length-1)
|
||||
/* if we've just finished a 32-bit int, print a space */
|
||||
dest[++j] = ' ';
|
||||
}
|
||||
|
@ -731,12 +737,22 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
|||
intBuffer[i] = network_int_to_host (intBuffer[i]);
|
||||
}
|
||||
|
||||
- (id) copy
|
||||
{
|
||||
return [self copyWithZone: NSDefaultMallocZone()];
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone*)zone
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) mutableCopy
|
||||
{
|
||||
return [self mutableCopyWithZone: NSDefaultMallocZone()];
|
||||
}
|
||||
|
||||
- (id) mutableCopyWithZone: (NSZone*)zone
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
|
@ -825,6 +841,13 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
|||
autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithData: (NSData*)data
|
||||
{
|
||||
return [[[NSMutableDataMalloc alloc] initWithBytes: [data bytes]
|
||||
length: [data length]]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithLength: (unsigned int)length
|
||||
{
|
||||
return [[[NSMutableDataMalloc alloc] initWithLength:length]
|
||||
|
@ -933,6 +956,14 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
|||
memset((char*)[self bytes] + aRange.location, 0, aRange.length);
|
||||
}
|
||||
|
||||
- (void) setData: (NSData*)data
|
||||
{
|
||||
NSRange r = NSMakeRange(0, [data length]);
|
||||
|
||||
[self setCapacity: [data length]];
|
||||
[self replaceBytesInRange: r withBytes: [data bytes]];
|
||||
}
|
||||
|
||||
// Serializing Data
|
||||
|
||||
- (void)serializeAlignedBytesLength:(unsigned int)length
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue