OLD | NEW |
1 /* Copyright (c) 2007, Google Inc. | 1 /* Copyright (c) 2007, Google Inc. |
2 * All rights reserved. | 2 * All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 } | 211 } |
212 } | 212 } |
213 } | 213 } |
214 return 0; | 214 return 0; |
215 } | 215 } |
216 | 216 |
217 | 217 |
218 // ----------------------------------------------------------------------- | 218 // ----------------------------------------------------------------------- |
219 // These functions replace system-alloc.cc | 219 // These functions replace system-alloc.cc |
220 | 220 |
221 // The current system allocator. Because we don't link with system-alloc.cc, | |
222 // we need to define our own. | |
223 SysAllocator* sys_alloc = NULL; | |
224 | |
225 // This is mostly like MmapSysAllocator::Alloc, except it does these weird | 221 // This is mostly like MmapSysAllocator::Alloc, except it does these weird |
226 // munmap's in the middle of the page, which is forbidden in windows. | 222 // munmap's in the middle of the page, which is forbidden in windows. |
227 extern void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size, | 223 extern void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size, |
228 size_t alignment) { | 224 size_t alignment) { |
229 // Align on the pagesize boundary | 225 // Align on the pagesize boundary |
230 const int pagesize = getpagesize(); | 226 const int pagesize = getpagesize(); |
231 if (alignment < pagesize) alignment = pagesize; | 227 if (alignment < pagesize) alignment = pagesize; |
232 size = ((size + alignment - 1) / alignment) * alignment; | 228 size = ((size + alignment - 1) / alignment) * alignment; |
233 | 229 |
234 // Report the total number of bytes the OS actually delivered. This might be | 230 // Report the total number of bytes the OS actually delivered. This might be |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 } | 301 } |
306 | 302 |
307 bool RegisterSystemAllocator(SysAllocator *allocator, int priority) { | 303 bool RegisterSystemAllocator(SysAllocator *allocator, int priority) { |
308 return false; // we don't allow registration on windows, right now | 304 return false; // we don't allow registration on windows, right now |
309 } | 305 } |
310 | 306 |
311 void DumpSystemAllocatorStats(TCMalloc_Printer* printer) { | 307 void DumpSystemAllocatorStats(TCMalloc_Printer* printer) { |
312 // We don't dump stats on windows, right now | 308 // We don't dump stats on windows, right now |
313 } | 309 } |
314 | 310 |
| 311 // The current system allocator |
| 312 SysAllocator* sys_alloc = NULL; |
| 313 |
315 | 314 |
316 // ----------------------------------------------------------------------- | 315 // ----------------------------------------------------------------------- |
317 // These functions rework existing functions of the same name in the | 316 // These functions rework existing functions of the same name in the |
318 // Google codebase. | 317 // Google codebase. |
319 | 318 |
320 // A replacement for HeapProfiler::CleanupOldProfiles. | 319 // A replacement for HeapProfiler::CleanupOldProfiles. |
321 void DeleteMatchingFiles(const char* prefix, const char* full_glob) { | 320 void DeleteMatchingFiles(const char* prefix, const char* full_glob) { |
322 WIN32_FIND_DATAA found; // that final A is for Ansi (as opposed to Unicode) | 321 WIN32_FIND_DATAA found; // that final A is for Ansi (as opposed to Unicode) |
323 HANDLE hFind = FindFirstFileA(full_glob, &found); // A is for Ansi | 322 HANDLE hFind = FindFirstFileA(full_glob, &found); // A is for Ansi |
324 if (hFind != INVALID_HANDLE_VALUE) { | 323 if (hFind != INVALID_HANDLE_VALUE) { |
325 const int prefix_length = strlen(prefix); | 324 const int prefix_length = strlen(prefix); |
326 do { | 325 do { |
327 const char *fname = found.cFileName; | 326 const char *fname = found.cFileName; |
328 if ((strlen(fname) >= prefix_length) && | 327 if ((strlen(fname) >= prefix_length) && |
329 (memcmp(fname, prefix, prefix_length) == 0)) { | 328 (memcmp(fname, prefix, prefix_length) == 0)) { |
330 RAW_VLOG(0, "Removing old heap profile %s\n", fname); | 329 RAW_VLOG(0, "Removing old heap profile %s\n", fname); |
331 // TODO(csilvers): we really need to unlink dirname + fname | 330 // TODO(csilvers): we really need to unlink dirname + fname |
332 _unlink(fname); | 331 _unlink(fname); |
333 } | 332 } |
334 } while (FindNextFileA(hFind, &found) != FALSE); // A is for Ansi | 333 } while (FindNextFileA(hFind, &found) != FALSE); // A is for Ansi |
335 FindClose(hFind); | 334 FindClose(hFind); |
336 } | 335 } |
337 } | 336 } |
OLD | NEW |