Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb629fc7 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Replace Vector _grow/_shrink checks with assert."

parents a2fd1773 686f62fc
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -347,8 +347,9 @@ void* VectorImpl::_grow(size_t where, size_t amount)
//    LOGV("_grow(this=%p, where=%d, amount=%d) count=%d, capacity=%d",
//        this, (int)where, (int)amount, (int)mCount, (int)capacity());

    if (where > mCount)
        where = mCount;
    LOG_ASSERT(where <= mCount,
            "[%p] _grow: where=%d, amount=%d, count=%d",
            this, (int)where, (int)amount, (int)mCount); // caller already checked

    const size_t new_size = mCount + amount;
    if (capacity() < new_size) {
@@ -400,8 +401,9 @@ void VectorImpl::_shrink(size_t where, size_t amount)
//    LOGV("_shrink(this=%p, where=%d, amount=%d) count=%d, capacity=%d",
//        this, (int)where, (int)amount, (int)mCount, (int)capacity());

    if (where >= mCount)
        where = mCount - amount;
    LOG_ASSERT(where + amount <= mCount,
            "[%p] _shrink: where=%d, amount=%d, count=%d",
            this, (int)where, (int)amount, (int)mCount); // caller already checked

    const size_t new_size = mCount - amount;
    if (new_size*3 < capacity()) {