aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/private
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2017-03-10 11:51:07 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-10 17:28:04 +0000
commit053730de732922ecee21be665af111ce671ce045 (patch)
treea888069700f090ebe9d2b210d53e54e5efcfa2d2 /include/private
parent566e53c7003920ff45c72498754060804b657c68 (diff)
Fix SkTHashTable dangling values
The element rearrange logic in SkTHashTable::remove() marks empty slots as such, but does not reset their value. When breaking out of the rearrange loop, we must also reset the last empty slot value to avoid retaining unwanted copies. Change-Id: I8ba2a25088c0aa5210277124e0917224cb295691 Reviewed-on: https://skia-review.googlesource.com/9533 Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'include/private')
-rw-r--r--include/private/SkTHash.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/include/private/SkTHash.h b/include/private/SkTHash.h
index 943129f8a9..2388905c38 100644
--- a/include/private/SkTHash.h
+++ b/include/private/SkTHash.h
@@ -95,7 +95,6 @@ public:
for (;;) {
Slot& emptySlot = fSlots[index];
int emptyIndex = index;
- emptySlot.markEmpty();
int originalIndex;
// Look for an element that can be moved into the empty slot.
// If the empty slot is in between where an element landed, and its native slot, then
@@ -106,7 +105,11 @@ public:
do {
index = this->next(index);
Slot& s = fSlots[index];
- if (s.empty()) { return; }
+ if (s.empty()) {
+ // We're done shuffling elements around. Clear the last empty slot.
+ emptySlot = Slot();
+ return;
+ }
originalIndex = s.hash & (fCapacity - 1);
} while ((index <= originalIndex && originalIndex < emptyIndex)
|| (originalIndex < emptyIndex && emptyIndex < index)
@@ -205,8 +208,6 @@ private:
bool empty() const { return this->hash == 0; }
- void markEmpty() { this->hash = 0; }
-
T val;
uint32_t hash;
};