database: Mark new entries valid based on id

I was using _size as an index into the database, but _size represents
the total number of valid rows and not the id of the new item.  If a row
is deleted _size will decrease and the wrong entries will be marked
valid.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2013-12-22 16:02:15 -05:00 committed by Anna Schumaker
parent b759b9743d
commit ff0fead24e
1 changed files with 1 additions and 1 deletions

View File

@ -114,7 +114,7 @@ unsigned int Database<T, U> :: insert(T val)
id = db.size();
db.push_back(val);
keys.insert(std::pair<U, unsigned int>(val.primary_key(), id));
db[_size].valid = true;
db[id].valid = true;
_size++;
return id;
}