mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
* src/NSData.m ([NSData +allocWithZone:]): New method.
([NSMutableData +allocWithZone:]): Likewise. ([NSData +data, +dataWithBytes:length:, +dataWithBytesNoCopy:length:, +dataWithContentsOfFile:, +dataWithContentsOfMappedFile:]): Allocate using designated allocator. ([NSMutableData +dataWithCapacity:, +dataWithLength:]): Likewise. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@575 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
805d7d9c0f
commit
46f15290d6
1 changed files with 16 additions and 9 deletions
|
@ -61,25 +61,28 @@ static Class NSMutableData_concrete_class;
|
|||
}
|
||||
|
||||
// Allocating and Initializing a Data Object
|
||||
+ allocWithZone:(NSZone *)zone
|
||||
{
|
||||
return NSAllocateObject([self _concreteClass], 0, zone);
|
||||
}
|
||||
|
||||
+ (id) data
|
||||
{
|
||||
return [[[[self _concreteClass] alloc] init]
|
||||
return [[[self alloc] init]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithBytes: (const void*)bytes
|
||||
length: (unsigned int)length
|
||||
{
|
||||
return [[[[self _concreteClass] alloc] initWithBytes:bytes length:length]
|
||||
return [[[self alloc] initWithBytes:bytes length:length]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithBytesNoCopy: (void*)bytes
|
||||
length: (unsigned int)length
|
||||
{
|
||||
return [[[[self _concreteClass] alloc]
|
||||
initWithBytesNoCopy:bytes length:length]
|
||||
return [[[self alloc] initWithBytesNoCopy:bytes length:length]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
|
@ -88,13 +91,13 @@ static Class NSMutableData_concrete_class;
|
|||
* though. */
|
||||
+ (id)dataWithContentsOfFile: (NSString*)path
|
||||
{
|
||||
return [[[[self _concreteClass] alloc] initWithContentsOfFile:path]
|
||||
return [[[self alloc] initWithContentsOfFile:path]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithContentsOfMappedFile: (NSString*)path
|
||||
{
|
||||
return [[[[self _concreteClass] alloc] initWithContentsOfMappedFile:path]
|
||||
return [[[self alloc] initWithContentsOfMappedFile:path]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
|
@ -473,16 +476,20 @@ static Class NSMutableData_concrete_class;
|
|||
|
||||
@implementation NSMutableData
|
||||
|
||||
+ allocWithZone:(NSZone *)zone
|
||||
{
|
||||
return NSAllocateObject([self _mutableConcreteClass], 0, zone);
|
||||
}
|
||||
|
||||
+ (id) dataWithCapacity: (unsigned int)numBytes
|
||||
{
|
||||
return [[[[[self _mutableConcreteClass] class] alloc]
|
||||
initWithCapacity:numBytes]
|
||||
return [[[self alloc] initWithCapacity:numBytes]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithLength: (unsigned int)length
|
||||
{
|
||||
return [[[[[self _mutableConcreteClass] class] alloc] initWithLength:length]
|
||||
return [[[self alloc] initWithLength:length]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue