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

Side by Side Diff: base/process/memory_win.cc

Issue 55333002: Make possible to check memory allocations inside chromium (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: improve testing code Created 6 years, 9 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/process/memory.h" 5 #include "base/process/memory.h"
6 6
7 #include <psapi.h> 7 #include <psapi.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 HMODULE instance = NULL; 75 HMODULE instance = NULL;
76 if (!::GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | 76 if (!::GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
77 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, 77 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
78 static_cast<char*>(address), 78 static_cast<char*>(address),
79 &instance)) { 79 &instance)) {
80 NOTREACHED(); 80 NOTREACHED();
81 } 81 }
82 return instance; 82 return instance;
83 } 83 }
84 84
85 // TODO(b.kelemen): implement it with the required semantics. On Linux this is
86 // implemented with a weak symbol that is overridden by tcmalloc. This is
87 // neccessary because base cannot have a direct dependency on tcmalloc. Since
88 // weak symbols are not supported on Windows this will involve some build time
89 // magic, much like what is done for libcrt in order to override the allocation
90 // functions.
91 bool UncheckedMalloc(size_t size, void** result) {
92 *result = malloc(size);
93 return *result != NULL;
94 }
95
85 } // namespace base 96 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698