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

Unified Diff: third_party/tcmalloc/win_allocator.cc

Issue 165275: Major changes to the Chrome allocator.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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 | « third_party/tcmalloc/tcmalloc.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/tcmalloc/win_allocator.cc
===================================================================
--- third_party/tcmalloc/win_allocator.cc (revision 0)
+++ third_party/tcmalloc/win_allocator.cc (revision 0)
@@ -0,0 +1,46 @@
+// Copyright (c) 2009 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.
+
+// This is a simple allocator based on the windows heap.
+
+extern "C" {
+
+HANDLE win_heap;
+
+bool win_heap_init(bool use_lfh) {
+ win_heap = HeapCreate(0, 0, 0);
+ if (win_heap == NULL)
+ return false;
+
+ if (use_lfh) {
+ ULONG enable_lfh = 2;
+ HeapSetInformation(win_heap, HeapCompatibilityInformation,
+ &enable_lfh, sizeof(enable_lfh));
+ // NOTE: Setting LFH may fail. Vista already has it enabled.
+ // And under the debugger, it won't use LFH. So we
+ // ignore any errors.
+ }
+
+ return true;
+}
+
+void* win_heap_malloc(size_t s) {
+ return HeapAlloc(win_heap, 0, s);
+}
+
+void* win_heap_realloc(void* p, size_t s) {
+ if (!p)
+ return win_heap_malloc(s);
+ return HeapReAlloc(win_heap, 0, p, s);
+}
+
+void win_heap_free(void* s) {
+ HeapFree(win_heap, 0, s);
+}
+
+size_t win_heap_msize(void* p) {
+ return HeapSize(win_heap, 0, p);
+}
+
+} // extern "C"
« no previous file with comments | « third_party/tcmalloc/tcmalloc.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698