Chromium Code Reviews| Index: third_party/tcmalloc/chromium/src/system-alloc.cc |
| =================================================================== |
| --- third_party/tcmalloc/chromium/src/system-alloc.cc (revision 110522) |
| +++ third_party/tcmalloc/chromium/src/system-alloc.cc (working copy) |
| @@ -103,8 +103,7 @@ |
| static SpinLock spinlock(SpinLock::LINKER_INITIALIZED); |
| -#if defined(HAVE_MMAP) || defined(MADV_DONTNEED) |
| -// Page size is initialized on demand (only needed for mmap-based allocators) |
| +#ifdef HAVE_GETPAGESIZE |
| static size_t pagesize = 0; |
| #endif |
| @@ -484,6 +483,21 @@ |
| return result; |
| } |
| +size_t TCMalloc_SystemAddGuard(void* start, size_t size) { |
| +#ifdef HAVE_GETPAGESIZE |
| + if (pagesize == 0) |
| + pagesize = getpagesize(); |
| + |
| + if (size < pagesize || (reinterpret_cast<size_t>(start) % pagesize) != 0) |
|
jar (doing other things)
2011/11/24 01:08:07
Perhaps you could be cautious, and check that the
jschuh
2011/11/28 18:33:36
It seems sufficient to just crash in PageAllocator
|
| + return 0; |
| + |
| + if (!mprotect(start, pagesize, PROT_NONE)) |
| + return pagesize; |
| +#endif |
| + |
| + return 0; |
| +} |
| + |
| void TCMalloc_SystemRelease(void* start, size_t length) { |
| #ifdef MADV_DONTNEED |
| if (FLAGS_malloc_devmem_start) { |