| 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 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 #define NOMINMAX // so std::max, below, compiles correctly | 38 #define NOMINMAX // so std::max, below, compiles correctly |
| 39 #include <config.h> | 39 #include <config.h> |
| 40 #include <string.h> // for strlen(), memset(), memcmp() | 40 #include <string.h> // for strlen(), memset(), memcmp() |
| 41 #include <assert.h> | 41 #include <assert.h> |
| 42 #include <stdarg.h> // for va_list, va_start, va_end | 42 #include <stdarg.h> // for va_list, va_start, va_end |
| 43 #include <windows.h> | 43 #include <windows.h> |
| 44 #include "port.h" | 44 #include "port.h" |
| 45 #include "base/logging.h" | 45 #include "base/logging.h" |
| 46 #include "base/spinlock.h" | 46 #include "base/spinlock.h" |
| 47 #include "internal_logging.h" |
| 47 #include "system-alloc.h" | 48 #include "system-alloc.h" |
| 48 | 49 |
| 49 // ----------------------------------------------------------------------- | 50 // ----------------------------------------------------------------------- |
| 50 // Basic libraries | 51 // Basic libraries |
| 51 | 52 |
| 52 int getpagesize() { | 53 int getpagesize() { |
| 53 static int pagesize = 0; | 54 static int pagesize = 0; |
| 54 if (pagesize == 0) { | 55 if (pagesize == 0) { |
| 55 SYSTEM_INFO system_info; | 56 SYSTEM_INFO system_info; |
| 56 GetSystemInfo(&system_info); | 57 GetSystemInfo(&system_info); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 } | 259 } |
| 259 | 260 |
| 260 bool RegisterSystemAllocator(SysAllocator *allocator, int priority) { | 261 bool RegisterSystemAllocator(SysAllocator *allocator, int priority) { |
| 261 return false; // we don't allow registration on windows, right now | 262 return false; // we don't allow registration on windows, right now |
| 262 } | 263 } |
| 263 | 264 |
| 264 void DumpSystemAllocatorStats(TCMalloc_Printer* printer) { | 265 void DumpSystemAllocatorStats(TCMalloc_Printer* printer) { |
| 265 // We don't dump stats on windows, right now | 266 // We don't dump stats on windows, right now |
| 266 } | 267 } |
| 267 | 268 |
| 269 // The current system allocator |
| 270 SysAllocator* sys_alloc = NULL; |
| 271 |
| 268 | 272 |
| 269 // ----------------------------------------------------------------------- | 273 // ----------------------------------------------------------------------- |
| 270 // These functions rework existing functions of the same name in the | 274 // These functions rework existing functions of the same name in the |
| 271 // Google codebase. | 275 // Google codebase. |
| 272 | 276 |
| 273 // A replacement for HeapProfiler::CleanupOldProfiles. | 277 // A replacement for HeapProfiler::CleanupOldProfiles. |
| 274 void DeleteMatchingFiles(const char* prefix, const char* full_glob) { | 278 void DeleteMatchingFiles(const char* prefix, const char* full_glob) { |
| 275 WIN32_FIND_DATAA found; // that final A is for Ansi (as opposed to Unicode) | 279 WIN32_FIND_DATAA found; // that final A is for Ansi (as opposed to Unicode) |
| 276 HANDLE hFind = FindFirstFileA(full_glob, &found); // A is for Ansi | 280 HANDLE hFind = FindFirstFileA(full_glob, &found); // A is for Ansi |
| 277 if (hFind != INVALID_HANDLE_VALUE) { | 281 if (hFind != INVALID_HANDLE_VALUE) { |
| 278 const int prefix_length = strlen(prefix); | 282 const int prefix_length = strlen(prefix); |
| 279 do { | 283 do { |
| 280 const char *fname = found.cFileName; | 284 const char *fname = found.cFileName; |
| 281 if ((strlen(fname) >= prefix_length) && | 285 if ((strlen(fname) >= prefix_length) && |
| 282 (memcmp(fname, prefix, prefix_length) == 0)) { | 286 (memcmp(fname, prefix, prefix_length) == 0)) { |
| 283 RAW_VLOG(0, "Removing old heap profile %s\n", fname); | 287 RAW_VLOG(0, "Removing old heap profile %s\n", fname); |
| 284 // TODO(csilvers): we really need to unlink dirname + fname | 288 // TODO(csilvers): we really need to unlink dirname + fname |
| 285 _unlink(fname); | 289 _unlink(fname); |
| 286 } | 290 } |
| 287 } while (FindNextFileA(hFind, &found) != FALSE); // A is for Ansi | 291 } while (FindNextFileA(hFind, &found) != FALSE); // A is for Ansi |
| 288 FindClose(hFind); | 292 FindClose(hFind); |
| 289 } | 293 } |
| 290 } | 294 } |
| OLD | NEW |