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:
parent
b759b9743d
commit
ff0fead24e
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue