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

Unified Diff: runtime/vm/dart_api_message.cc

Issue 16271010: Use 'new' in all the snapshot reallocation functions instead of realloc. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/dart_api_message.cc
===================================================================
--- runtime/vm/dart_api_message.cc (revision 23570)
+++ runtime/vm/dart_api_message.cc (working copy)
@@ -807,18 +807,20 @@
void ApiMessageWriter::AddToForwardList(Dart_CObject* object) {
if (forward_id_ >= forward_list_length_) {
Søren Gjesse 2013/06/04 06:54:47 Not related to this change, but shouldn't this con
siva 2013/06/05 16:21:31 Done.
- void* new_list = NULL;
+ intptr_t new_size;
+ intptr_t old_size;
if (forward_list_length_ == 0) {
+ old_size = 0;
forward_list_length_ = 4;
- intptr_t new_size = forward_list_length_ * sizeof(object);
- new_list = ::malloc(new_size);
+ new_size = forward_list_length_ * sizeof(object);
} else {
+ old_size = forward_list_length_ * sizeof(object);
+ new_size = old_size + old_size;
forward_list_length_ *= 2;
- intptr_t new_size = (forward_list_length_ * sizeof(object));
- new_list = ::realloc(forward_list_, new_size);
}
+ Dart_CObject** new_list = Utils::Realloc(forward_list_, old_size, new_size);
ASSERT(new_list != NULL);
- forward_list_ = reinterpret_cast<Dart_CObject**>(new_list);
+ forward_list_ = new_list;
}
forward_list_[forward_id_] = object;
forward_id_ += 1;

Powered by Google App Engine
This is Rietveld 408576698