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

Unified Diff: src/allocation.cc

Issue 5005001: Split globals.h into two parts, where only one depends on V8. (Closed)
Patch Set: Addressed review comments. Created 10 years, 1 month 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 | « src/allocation.h ('k') | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/allocation.cc
diff --git a/src/allocation.cc b/src/allocation.cc
index 678f4fd7d2f23495d1ed76adc03a0a17f07dc369..d74c37cd799499b32fe053fa5ceb2b1476547983 100644
--- a/src/allocation.cc
+++ b/src/allocation.cc
@@ -27,16 +27,21 @@
#include <stdlib.h>
-#include "v8.h"
+#include "../include/v8stdint.h"
+#include "globals.h"
+#include "checks.h"
+#include "allocation.h"
+#include "utils.h"
namespace v8 {
namespace internal {
-
void* Malloced::New(size_t size) {
ASSERT(NativeAllocationChecker::allocation_allowed());
void* result = malloc(size);
- if (result == NULL) V8::FatalProcessOutOfMemory("Malloced operator new");
+ if (result == NULL) {
+ v8::internal::FatalProcessOutOfMemory("Malloced operator new");
+ }
return result;
}
@@ -47,7 +52,7 @@ void Malloced::Delete(void* p) {
void Malloced::FatalProcessOutOfMemory() {
- V8::FatalProcessOutOfMemory("Out of memory");
+ v8::internal::FatalProcessOutOfMemory("Out of memory");
}
@@ -82,7 +87,7 @@ void AllStatic::operator delete(void* p) {
char* StrDup(const char* str) {
int length = StrLength(str);
char* result = NewArray<char>(length + 1);
- memcpy(result, str, length * kCharSize);
+ memcpy(result, str, length);
result[length] = '\0';
return result;
}
@@ -92,7 +97,7 @@ char* StrNDup(const char* str, int n) {
int length = StrLength(str);
if (n < length) length = n;
char* result = NewArray<char>(length + 1);
- memcpy(result, str, length * kCharSize);
+ memcpy(result, str, length);
result[length] = '\0';
return result;
}
@@ -124,6 +129,7 @@ void* PreallocatedStorage::New(size_t size) {
}
ASSERT(free_list_.next_ != &free_list_);
ASSERT(free_list_.previous_ != &free_list_);
+
size = (size + kPointerSize - 1) & ~(kPointerSize - 1);
// Search for exact fit.
for (PreallocatedStorage* storage = free_list_.next_;
« no previous file with comments | « src/allocation.h ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698