Ignore:
Timestamp:
Aug 14, 2007, 3:19:04 PM (18 years ago)
Author:
darin
Message:

Reviewed by Sam.

  • fix <rdar://problem/5410570> Global initializer introduced by use of std::numeric_limits in r24919
  • kjs/ustring.cpp: (KJS::overflowIndicator): Turned into a function. (KJS::maxUChars): Ditto. (KJS::allocChars): Use the functions. (KJS::reallocChars): Ditto. (KJS::UString::expandedSize): Ditto.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ustring.cpp

    r24919 r25078  
    5555extern const double Inf;
    5656
    57 static const size_t overflowIndicator = std::numeric_limits<size_t>::max();
    58 static const size_t maxUChars = std::numeric_limits<size_t>::max() / sizeof(UChar);
     57static inline const size_t overflowIndicator() { return std::numeric_limits<size_t>::max(); }
     58static inline const size_t maxUChars() { return std::numeric_limits<size_t>::max() / sizeof(UChar); }
    5959
    6060static inline UChar* allocChars(size_t length)
    6161{
    6262    ASSERT(length);
    63     if (length > maxUChars)
     63    if (length > maxUChars())
    6464        return 0;
    6565    return static_cast<UChar*>(fastMalloc(sizeof(UChar) * length));
     
    6969{
    7070    ASSERT(length);
    71     if (length > maxUChars)
     71    if (length > maxUChars())
    7272        return 0;
    7373    return static_cast<UChar*>(fastRealloc(buffer, sizeof(UChar) * length));
     
    351351    // we overflow the maximum value that we can handle.
    352352
    353     if (size > maxUChars)
    354         return overflowIndicator;
     353    if (size > maxUChars())
     354        return overflowIndicator();
    355355
    356356    size_t expandedSize = ((size + 10) / 10 * 11) + 1;
    357     if (maxUChars - expandedSize < otherSize)
    358         return overflowIndicator;
     357    if (maxUChars() - expandedSize < otherSize)
     358        return overflowIndicator();
    359359
    360360    return expandedSize + otherSize;
Note: See TracChangeset for help on using the changeset viewer.