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

Unified Diff: base/allocator/allocator_shim_default_dispatch_to_winheap.cc

Issue 2138173002: Hookup the generic heap intercept for Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Squash the use_experimental_allocator_shim for NaCL as per Brett's suggestion. Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/allocator/allocator_shim.cc ('k') | base/allocator/allocator_shim_override_ucrt_symbols_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/allocator/allocator_shim_default_dispatch_to_winheap.cc
diff --git a/base/allocator/allocator_shim_default_dispatch_to_winheap.cc b/base/allocator/allocator_shim_default_dispatch_to_winheap.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4d5a27429a33e16bf18eabc2a432fb2c0882f0eb
--- /dev/null
+++ b/base/allocator/allocator_shim_default_dispatch_to_winheap.cc
@@ -0,0 +1,56 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/allocator/allocator_shim.h"
+
+#include "base/allocator/winheap_stubs_win.h"
+#include "base/logging.h"
+
+namespace {
+
+using base::allocator::AllocatorDispatch;
+
+void* DefaultWinHeapMallocImpl(const AllocatorDispatch*, size_t size) {
+ return base::allocator::WinHeapMalloc(size);
+}
+
+void* DefaultWinHeapCallocImpl(const AllocatorDispatch* self,
+ size_t n,
+ size_t elem_size) {
+ // Overflow check.
+ const size_t size = n * elem_size;
+ if (elem_size != 0 && size / elem_size != n)
+ return nullptr;
+
+ void* result = DefaultWinHeapMallocImpl(self, size);
+ if (result) {
+ memset(result, 0, size);
+ }
+ return result;
+}
+
+void* DefaultWinHeapMemalignImpl(const AllocatorDispatch* self,
+ size_t alignment,
+ size_t size) {
+ CHECK(false) << "The windows heap does not support memalign.";
+ return nullptr;
+}
+
+void* DefaultWinHeapReallocImpl(const AllocatorDispatch* self,
+ void* address,
+ size_t size) {
+ return base::allocator::WinHeapRealloc(address, size);
+}
+
+void DefaultWinHeapFreeImpl(const AllocatorDispatch*, void* address) {
+ base::allocator::WinHeapFree(address);
+}
+
+} // namespace
+
+const AllocatorDispatch AllocatorDispatch::default_dispatch = {
+ &DefaultWinHeapMallocImpl, &DefaultWinHeapCallocImpl,
+ &DefaultWinHeapMemalignImpl, &DefaultWinHeapReallocImpl,
+ &DefaultWinHeapFreeImpl, nullptr, /* next */
+};
« no previous file with comments | « base/allocator/allocator_shim.cc ('k') | base/allocator/allocator_shim_override_ucrt_symbols_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698