From: Peter Edberg Date: Wed, 14 Sep 2011 21:27:45 +0000 (+0000) Subject: ICU-8794 Ensure that TextFile::ensureCapacity initial loop value is at least 64,... X-Git-Tag: milestone-59-0-1~4524 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7bb51b02e8b629fe080f4a7b336eb84ac53591e8;p=icu ICU-8794 Ensure that TextFile::ensureCapacity initial loop value is at least 64, quiet a warning. X-SVN-Rev: 30656 --- diff --git a/icu4c/source/test/intltest/textfile.cpp b/icu4c/source/test/intltest/textfile.cpp index fe193b0fcbd..e55169dc56d 100644 --- a/icu4c/source/test/intltest/textfile.cpp +++ b/icu4c/source/test/intltest/textfile.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (c) 2004, International Business Machines +* Copyright (c) 2004,2011 International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Author: Alan Liu @@ -145,6 +145,7 @@ UBool TextFile::setBuffer(int32_t index, char c, UErrorCode& ec) { * Return TRUE upon success. Upon return, 'buffer' may change * value. In any case, previous contents are preserved. */ + #define LOWEST_MIN_CAPACITY 64 UBool TextFile::ensureCapacity(int32_t mincapacity) { if (capacity >= mincapacity) { return TRUE; @@ -152,8 +153,8 @@ UBool TextFile::ensureCapacity(int32_t mincapacity) { // Grow by factor of 2 to prevent frequent allocation // Note: 'capacity' may be 0 - int32_t i; - for (i = capacity || 1024; i < mincapacity; ) { + int32_t i = (capacity < LOWEST_MIN_CAPACITY)? LOWEST_MIN_CAPACITY: capacity; + while (i < mincapacity) { i <<= 1; if (i < 0) { i = 0x7FFFFFFF;