winheap_stubs_win.h 1.6 KB

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