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

Side by Side Diff: src/hashmap.cc

Issue 159192: Fix some defects identifies by Coverity Prevent. All are false... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/ia32/codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 187 }
188 } 188 }
189 189
190 return p; 190 return p;
191 } 191 }
192 192
193 193
194 void HashMap::Initialize(uint32_t capacity) { 194 void HashMap::Initialize(uint32_t capacity) {
195 ASSERT(IsPowerOf2(capacity)); 195 ASSERT(IsPowerOf2(capacity));
196 map_ = reinterpret_cast<Entry*>(allocator_->New(capacity * sizeof(Entry))); 196 map_ = reinterpret_cast<Entry*>(allocator_->New(capacity * sizeof(Entry)));
197 if (map_ == NULL) V8::FatalProcessOutOfMemory("HashMap::Initialize"); 197 if (map_ == NULL) {
198 V8::FatalProcessOutOfMemory("HashMap::Initialize");
199 return;
200 }
198 capacity_ = capacity; 201 capacity_ = capacity;
199 Clear(); 202 Clear();
200 } 203 }
201 204
202 205
203 void HashMap::Resize() { 206 void HashMap::Resize() {
204 Entry* map = map_; 207 Entry* map = map_;
205 uint32_t n = occupancy_; 208 uint32_t n = occupancy_;
206 209
207 // Allocate larger map. 210 // Allocate larger map.
208 Initialize(capacity_ * 2); 211 Initialize(capacity_ * 2);
209 212
210 // Rehash all current entries. 213 // Rehash all current entries.
211 for (Entry* p = map; n > 0; p++) { 214 for (Entry* p = map; n > 0; p++) {
212 if (p->key != NULL) { 215 if (p->key != NULL) {
213 Lookup(p->key, p->hash, true)->value = p->value; 216 Lookup(p->key, p->hash, true)->value = p->value;
214 n--; 217 n--;
215 } 218 }
216 } 219 }
217 220
218 // Delete old map. 221 // Delete old map.
219 allocator_->Delete(map); 222 allocator_->Delete(map);
220 } 223 }
221 224
222 225
223 } } // namespace v8::internal 226 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/ia32/codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698