From b7b35b32a554cd764d655ac4f453b79c1251ac39 Mon Sep 17 00:00:00 2001 From: mccallum Date: Wed, 2 Aug 1995 14:51:26 +0000 Subject: [PATCH] ([NSData +allocWithZone:]): New method. (_initWithBytesNoCopy:length): New (designated initializer) method. (initWithBytesNoCopy:length:): Make subclass responsibility. (init): Call new designated initializer. ([NSMutableData +allocWithZone:]) New Method. (dataWithCapacity:, dataWithLength:): Allocate using designated allocator. (initWithBytesNoCopy:length:): Make subclass responsibility. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@501 72102866-910b-0410-8b05-ffd578937521 --- Source/NSData.m | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Source/NSData.m b/Source/NSData.m index 4444cb070..be4d25ebb 100644 --- a/Source/NSData.m +++ b/Source/NSData.m @@ -108,18 +108,21 @@ static Class NSMutableData_concrete_class; return [self initWithBytesNoCopy:buf length:length]; } -/* This is the designated initializer for NSData */ +/* This is the (internal) designated initializer for NSData. This routine + should only be called by known subclasses of NSData. Other subclasses + should just use [super init]. */ +- (id) _initWithBytesNoCopy: (void*)bytes + length: (unsigned int)length +{ + return [super init]; +} + - (id) initWithBytesNoCopy: (void*)bytes length: (unsigned int)length { - /* FIXME: Shouldn't this call [super init], rather than - * [self notImplemented:]? Otherwise, how are subclasses supposed - * to initialize their NSObject instance variables? Although I - * notice that the concrete subclasses are doing strange things; so - * maybe this doesn't matter. */ /* xxx Eventually we'll have to be aware of malloc'ed memory vs vm_allocate'd memory, etc. */ - [self notImplemented:_cmd]; + [self subclassResponsibility:_cmd]; return nil; } @@ -129,7 +132,7 @@ static Class NSMutableData_concrete_class; /* FIXME: It seems so; mutable subclasses need to deal gracefully * with NULL pointers and/or 0 length data objects, though. Which * they do. */ - return [self initWithBytesNoCopy:NULL length:0]; + return [self _initWithBytesNoCopy:NULL length:0]; } - (id) initWithContentsOfFile: (NSString *)path @@ -489,13 +492,12 @@ static Class NSMutableData_concrete_class; length:capacity]; } -/* This is the designated initializer */ - (id) initWithBytesNoCopy: (void*)bytes length: (unsigned int)length { /* xxx Eventually we'll have to be aware of malloc'ed memory vs vm_allocate'd memory, etc. */ - [self notImplemented:_cmd]; + [self subclassResponsibility:_cmd]; return nil; }