Chromium Code Reviews| 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); |
|
Rico
2010/11/15 13:10:16
do we know that kCharSize is always 1?
Lasse Reichstein
2010/11/15 13:21:10
Yes. kCharSize is defined as sizeof(char), and tha
|
| 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_; |