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

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: Fix dangling use of ::g_win_new_mode. 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
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..fec64c121cfc544a35cbf56180830a26fa2169ad
--- /dev/null
+++ b/base/allocator/allocator_shim_default_dispatch_to_winheap.cc
@@ -0,0 +1,48 @@
+// 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/allocator_impl_win.h"
+#include "base/logging.h"
+
+namespace {
+
+using base::allocator::AllocatorDispatch;
+
+void* WinHeapMalloc(const AllocatorDispatch*, size_t size) {
Primiano Tucci (use gerrit) 2016/07/12 14:51:05 Can you add some prefix to these functions (DoWinH
Sigurður Ásgeirsson 2016/07/14 19:04:27 Yeah, naming - I went apeshit with prefix and suff
+ return base::allocator::WinHeapMalloc(size);
+}
+
+void* WinHeapCalloc(const AllocatorDispatch* self, size_t n, size_t elem_size) {
+ return base::allocator::WinHeapCalloc(n, elem_size);
+}
+
+void* WinHeapMemalign(const AllocatorDispatch* self,
+ size_t alignment,
+ size_t size) {
+ NOTREACHED() << "The windows heap does not support memalign.";
Primiano Tucci (use gerrit) 2016/07/12 14:51:05 I'd make this a CHECK(false), so shows up in produ
Sigurður Ásgeirsson 2016/07/14 19:04:27 Done.
+ return nullptr;
+}
+
+void* WinHeapRealloc(const AllocatorDispatch* self,
+ void* address,
+ size_t size) {
+ return base::allocator::WinHeapRealloc(address, size);
+}
+
+void WinHeapFree(const AllocatorDispatch*, void* address) {
+ base::allocator::WinHeapFree(address);
+}
+
+} // namespace
+
+const AllocatorDispatch AllocatorDispatch::default_dispatch = {
+ &WinHeapMalloc,
+ &WinHeapCalloc,
+ &WinHeapMemalign,
+ &WinHeapRealloc,
+ &WinHeapFree,
+ nullptr, /* next */
+};

Powered by Google App Engine
This is Rietveld 408576698