Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: runtime/vm/hash_map.h

Issue 2647763002: Fixed segfault in Remove method. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_HASH_MAP_H_ 5 #ifndef RUNTIME_VM_HASH_MAP_H_
6 #define RUNTIME_VM_HASH_MAP_H_ 6 #define RUNTIME_VM_HASH_MAP_H_
7 7
8 #include "vm/growable_array.h" // For Malloc, EmptyBase 8 #include "vm/growable_array.h" // For Malloc, EmptyBase
9 #include "vm/zone.h" 9 #include "vm/zone.h"
10 10
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 lists_[next] = HashMapListElement(); 325 lists_[next] = HashMapListElement();
326 lists_[next].next = free_list_head_; 326 lists_[next].next = free_list_head_;
327 free_list_head_ = next; 327 free_list_head_ = next;
328 } 328 }
329 count_--; 329 count_--;
330 return true; 330 return true;
331 } 331 }
332 332
333 intptr_t current = array_[pos].next; 333 intptr_t current = array_[pos].next;
334 334
335 // If there's only the single element in the bucket and it does not match the
336 // key to be removed, just return.
337 if (current == kNil) {
338 return false;
339 }
340
335 // Check the case where the second element in the bucket is the one to be 341 // Check the case where the second element in the bucket is the one to be
336 // removed. 342 // removed.
337 if (KeyValueTrait::KeyOf(lists_[current].kv) == key) { 343 if (KeyValueTrait::KeyOf(lists_[current].kv) == key) {
338 array_[pos].next = lists_[current].next; 344 array_[pos].next = lists_[current].next;
339 lists_[current] = HashMapListElement(); 345 lists_[current] = HashMapListElement();
340 lists_[current].next = free_list_head_; 346 lists_[current].next = free_list_head_;
341 free_list_head_ = current; 347 free_list_head_ = current;
342 count_--; 348 count_--;
343 return true; 349 return true;
344 } 350 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 437
432 static Key KeyOf(Pair kv) { return kv.key; } 438 static Key KeyOf(Pair kv) { return kv.key; }
433 static Value ValueOf(Pair kv) { return kv.value; } 439 static Value ValueOf(Pair kv) { return kv.value; }
434 static intptr_t Hashcode(Key key) { return reinterpret_cast<intptr_t>(key); } 440 static intptr_t Hashcode(Key key) { return reinterpret_cast<intptr_t>(key); }
435 static bool IsKeyEqual(Pair kv, Key key) { return kv.key == key; } 441 static bool IsKeyEqual(Pair kv, Key key) { return kv.key == key; }
436 }; 442 };
437 443
438 } // namespace dart 444 } // namespace dart
439 445
440 #endif // RUNTIME_VM_HASH_MAP_H_ 446 #endif // RUNTIME_VM_HASH_MAP_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698