Logo Search packages:      
Sourcecode: icu version File versions  Download package

UBool MessageFormat::allocateArgTypes ( int32_t  capacity  )  [private]

Allocate argTypes[] to at least the given capacity and return TRUE if successful. If not, leave argTypes[] unchanged.

If argTypes is NULL, allocate it. If it is not NULL, enlarge it if necessary to be at least as large as specified.

Definition at line 430 of file msgfmt.cpp.

References argTypes, FALSE, Formattable::kString, NULL, and TRUE.

Referenced by makeFormat(), MessageFormat(), and operator=().

                                                      {
    if (argTypes == NULL) {
        argTypes = (Formattable::Type*) uprv_malloc(sizeof(*argTypes) * capacity);
        argTypeCount = 0;
        argTypeCapacity = capacity;
        if (argTypes == NULL) {
            argTypeCapacity = 0;
            return FALSE;
        }
        for (int32_t i=0; i<capacity; ++i) {
            argTypes[i] = Formattable::kString;
        }
    } else if (argTypeCapacity < capacity) {
        if (capacity < 2*argTypeCapacity) {
            capacity = 2*argTypeCapacity;
        }
        Formattable::Type* a = (Formattable::Type*)
            uprv_realloc(argTypes, sizeof(*argTypes) * capacity);
        if (a == NULL) {
            return FALSE; // request failed
        }
        for (int32_t i=argTypeCapacity; i<capacity; ++i) {
            a[i] = Formattable::kString;
        }
        argTypes = a;
        argTypeCapacity = capacity;
    }
    return TRUE;
}


Generated by  Doxygen 1.6.0   Back to index