diff options
author | Jeff Brown <jeffbrown@google.com> | 2011-07-14 16:52:10 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-14 16:52:10 -0700 |
commit | 50a3e420945583574913fb79c17dfebcd4911102 (patch) | |
tree | dc1b5cd24fa9a9a0965667d79024457cfa621024 | |
parent | 8a65e1fb57076c0f3157787112db36c112d7f37d (diff) | |
parent | 11bf79d6e3542e40ebd212b0f5d7cb3370f3068d (diff) | |
download | frameworks_base-50a3e420945583574913fb79c17dfebcd4911102.zip frameworks_base-50a3e420945583574913fb79c17dfebcd4911102.tar.gz frameworks_base-50a3e420945583574913fb79c17dfebcd4911102.tar.bz2 |
Merge "Replace Vector _grow/_shrink checks with assert."
-rw-r--r-- | libs/utils/VectorImpl.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libs/utils/VectorImpl.cpp b/libs/utils/VectorImpl.cpp index 87ae3d5..0701a51 100644 --- a/libs/utils/VectorImpl.cpp +++ b/libs/utils/VectorImpl.cpp @@ -347,9 +347,10 @@ 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) { const size_t new_capacity = max(kMinVectorCapacity, ((new_size*3)+1)/2); @@ -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()) { |