mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-1779 Better fix for malloc(0)
X-SVN-Rev: 8093
This commit is contained in:
parent
26516e852e
commit
f2aadf39e9
1 changed files with 4 additions and 4 deletions
|
@ -32,10 +32,6 @@ UVector::UVector(int32_t initialCapacity, UErrorCode &status) :
|
|||
deleter(0),
|
||||
comparer(0)
|
||||
{
|
||||
// Fix bogus initialCapacity values; avoid malloc(0)
|
||||
if (initialCapacity < 1) {
|
||||
initialCapacity = 1;
|
||||
}
|
||||
_init(initialCapacity, status);
|
||||
}
|
||||
|
||||
|
@ -60,6 +56,10 @@ UVector::UVector(UObjectDeleter d, UKeyComparator c, int32_t initialCapacity, UE
|
|||
}
|
||||
|
||||
void UVector::_init(int32_t initialCapacity, UErrorCode &status) {
|
||||
// Fix bogus initialCapacity values; avoid malloc(0)
|
||||
if (initialCapacity < 1) {
|
||||
initialCapacity = DEFUALT_CAPACITY;
|
||||
}
|
||||
elements = (UHashTok *)uprv_malloc(sizeof(UHashTok)*initialCapacity);
|
||||
if (elements == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
|
|
Loading…
Add table
Reference in a new issue