(initWithCapacity:): Make sure that capacity is greater than zero.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@312 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1995-04-07 20:56:20 +00:00
parent 17dbbe2248
commit 3d1c766353

View file

@ -173,11 +173,12 @@ stringDecrementCountAndFillHoleAt(NSMutableCStringStruct *self,
}
/* This is the designated initializer for this class */
/* xxx Should capacity include the '\0' terminator? */
- initWithCapacity: (unsigned)capacity
{
_count = 0;
_capacity = capacity;
OBJC_MALLOC(_contents_chars, char, _capacity+1);
_capacity = MAX(capacity, 2);
OBJC_MALLOC(_contents_chars, char, _capacity);
_contents_chars[0] = '\0';
return self;
}