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

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, 6 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
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/debuginfo.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_message.cc
===================================================================
--- runtime/vm/dart_api_message.cc (revision 23633)
+++ runtime/vm/dart_api_message.cc (working copy)
@@ -806,19 +806,22 @@
void ApiMessageWriter::AddToForwardList(Dart_CObject* object) {
- if (forward_id_ >= forward_list_length_) {
- void* new_list = NULL;
+ ASSERT(forward_id_ <= forward_list_length_);
+ if (forward_id_ == forward_list_length_) {
+ 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;
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/debuginfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698