• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Thin allocation wrappers for the windows heap. This file should be deleted
6 // once the win-specific allocation shim has been removed, and the generic shim
7 // has becaome the default.
8 
9 #ifndef BASE_ALLOCATOR_PARTITION_ALLOCATOR_SHIM_WINHEAP_STUBS_WIN_H_
10 #define BASE_ALLOCATOR_PARTITION_ALLOCATOR_SHIM_WINHEAP_STUBS_WIN_H_
11 
12 #include <stdint.h>
13 
14 #include "base/base_export.h"
15 
16 namespace allocator_shim {
17 
18 // Set to true if the link-time magic has successfully hooked into the CRT's
19 // heap initialization.
20 extern bool g_is_win_shim_layer_initialized;
21 
22 // Thin wrappers to implement the standard C allocation semantics on the
23 // CRT's Windows heap.
24 void* WinHeapMalloc(size_t size);
25 void WinHeapFree(void* ptr);
26 void* WinHeapRealloc(void* ptr, size_t size);
27 
28 // Returns a lower-bound estimate for the full amount of memory consumed by the
29 // the allocation |ptr|.
30 size_t WinHeapGetSizeEstimate(void* ptr);
31 
32 // Call the new handler, if one has been set.
33 // Returns true on successfully calling the handler, false otherwise.
34 bool WinCallNewHandler(size_t size);
35 
36 // Wrappers to implement the interface for the _aligned_* functions on top of
37 // the CRT's Windows heap. Exported for tests.
38 BASE_EXPORT void* WinHeapAlignedMalloc(size_t size, size_t alignment);
39 BASE_EXPORT void* WinHeapAlignedRealloc(void* ptr,
40                                         size_t size,
41                                         size_t alignment);
42 BASE_EXPORT void WinHeapAlignedFree(void* ptr);
43 
44 }  // namespace allocator_shim
45 
46 #endif  // BASE_ALLOCATOR_PARTITION_ALLOCATOR_SHIM_WINHEAP_STUBS_WIN_H_
47