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

Unified Diff: runtime/vm/zone.cc

Issue 2245063004: Improve error message when zone allocation fails. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/zone.cc
diff --git a/runtime/vm/zone.cc b/runtime/vm/zone.cc
index 0f6754fd15f1a4615c596cd56ae1502c3ebac002..743727a54f91a3abffc9b8b9efb41a1798ae8620 100644
--- a/runtime/vm/zone.cc
+++ b/runtime/vm/zone.cc
@@ -35,7 +35,7 @@ class Zone::Segment {
// Computes the address of the nth byte in this segment.
uword address(int n) { return reinterpret_cast<uword>(this) + n; }
- static void Delete(Segment* segment) { delete[] segment; }
+ static void Delete(Segment* segment) { free(segment); }
DISALLOW_IMPLICIT_CONSTRUCTORS(Segment);
};
@@ -57,16 +57,17 @@ void Zone::Segment::DeleteSegmentList(Segment* head) {
Zone::Segment* Zone::Segment::New(intptr_t size, Zone::Segment* next) {
ASSERT(size >= 0);
- Segment* result = reinterpret_cast<Segment*>(new uint8_t[size]);
+ Segment* result = reinterpret_cast<Segment*>(malloc(size));
+ if (result == NULL) {
+ FATAL("Out of memory.\n");
+ }
ASSERT(Utils::IsAligned(result->start(), Zone::kAlignment));
- if (result != NULL) {
#ifdef DEBUG
- // Zap the entire allocated segment (including the header).
- memset(result, kZapUninitializedByte, size);
+ // Zap the entire allocated segment (including the header).
+ memset(result, kZapUninitializedByte, size);
#endif
- result->next_ = next;
- result->size_ = size;
- }
+ result->next_ = next;
+ result->size_ = size;
return result;
}
« 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