Merge "Fix: wrong size checking in SparseTable."

main
Keisuke Kuroyanagi 2014-03-24 06:55:14 +00:00 committed by Android (Google) Code Review
commit 628a64847c
1 changed files with 5 additions and 7 deletions

View File

@ -41,13 +41,11 @@ uint32_t SparseTable::get(const int id) const {
bool SparseTable::set(const int id, const uint32_t value) {
const int posInIndexTable = getPosInIndexTable(id);
// Extends the index table if needed.
if (mIndexTableBuffer->getTailPosition() < posInIndexTable) {
int tailPos = mIndexTableBuffer->getTailPosition();
while(tailPos < posInIndexTable) {
if (!mIndexTableBuffer->writeUintAndAdvancePosition(NOT_EXIST, INDEX_SIZE, &tailPos)) {
AKLOGE("cannot extend index table. tailPos: %d to: %d", tailPos, posInIndexTable);
return false;
}
int tailPos = mIndexTableBuffer->getTailPosition();
while (tailPos <= posInIndexTable) {
if (!mIndexTableBuffer->writeUintAndAdvancePosition(NOT_EXIST, INDEX_SIZE, &tailPos)) {
AKLOGE("cannot extend index table. tailPos: %d to: %d", tailPos, posInIndexTable);
return false;
}
}
if (contains(id)) {