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

Unified Diff: runtime/vm/dart_api_message.cc

Issue 10557043: - Avoid doubling 0 when trying to determine a new size for the (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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_message.h ('k') | runtime/vm/vm_sources.gypi » ('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 8810)
+++ runtime/vm/dart_api_message.cc (working copy)
@@ -513,8 +513,14 @@
void ApiMessageWriter::AddToForwardList(Dart_CObject* object) {
if (forward_id_ >= forward_list_length_) {
- intptr_t new_size = (forward_list_length_ * sizeof(object)) * 2;
- void* new_list = ::realloc(forward_list_, new_size);
+ void* new_list = NULL;
+ if (forward_list_length_ == 0) {
+ intptr_t new_size = (4 * sizeof(object)) * 2;
+ new_list = ::malloc(new_size);
+ } else {
+ intptr_t new_size = (forward_list_length_ * sizeof(object)) * 2;
+ new_list = ::realloc(forward_list_, new_size);
+ }
ASSERT(new_list != NULL);
forward_list_ = reinterpret_cast<Dart_CObject**>(new_list);
}
« no previous file with comments | « runtime/vm/dart_api_message.h ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698