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

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

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

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

Definition at line 399 of file msgfmt.cpp.

References FALSE, NULL, subformats, and TRUE.

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

                                                        {
    if (subformats == NULL) {
        subformats = (Subformat*) uprv_malloc(sizeof(*subformats) * capacity);
        subformatCapacity = capacity;
        subformatCount = 0;
        if (subformats == NULL) {
            subformatCapacity = 0;
            return FALSE;
        }
    } else if (subformatCapacity < capacity) {
        if (capacity < 2*subformatCapacity) {
            capacity = 2*subformatCapacity;
        }
        Subformat* a = (Subformat*)
            uprv_realloc(subformats, sizeof(*subformats) * capacity);
        if (a == NULL) {
            return FALSE; // request failed
        }
        subformats = a;
        subformatCapacity = capacity;
    }
    return TRUE;
}


Generated by  Doxygen 1.6.0   Back to index