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

Unified Diff: src/zone.h

Issue 456663002: Make Zone::New() and Zone::NewArray() usable w/o v8.h. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | src/zone.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/zone.h
diff --git a/src/zone.h b/src/zone.h
index a689f1218f0d4e5d085e18a9287e482dace6699d..a690b8d8caf1bb6ec3144908f37b4e8736c982d8 100644
--- a/src/zone.h
+++ b/src/zone.h
@@ -5,6 +5,8 @@
#ifndef V8_ZONE_H_
#define V8_ZONE_H_
+#include <limits>
+
#include "src/allocation.h"
#include "src/base/logging.h"
#include "src/globals.h"
@@ -38,10 +40,14 @@ class Zone {
~Zone();
// Allocate 'size' bytes of memory in the Zone; expands the Zone by
// allocating new segments of memory on demand using malloc().
- inline void* New(int size);
+ void* New(int size);
template <typename T>
- inline T* NewArray(int length);
+ T* NewArray(int length) {
+ CHECK(std::numeric_limits<int>::max() / static_cast<int>(sizeof(T)) >
+ length);
+ return static_cast<T*>(New(length * sizeof(T)));
+ }
// Deletes all objects and free all memory allocated in the Zone. Keeps one
// small (size <= kMaximumKeptSegmentSize) segment around if it finds one.
« no previous file with comments | « no previous file | src/zone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698