52#error #include <hx/libhatchet.h> instead.
55#if HX_CPLUSPLUS && (HX_USE_LIBCXX)
64#if HX_CPLUSPLUS >= 202002L
69#define hxalignment static_cast<hxalignment_t>(alignof(max_align_t ))
71#define hxalignment (hxalignment_t)_Alignof(max_align_t )
156#if HX_CPLUSPLUS >= 202002L
157constexpr void*
operator new(size_t,
void* ptr_)
noexcept {
return ptr_; }
158constexpr void*
operator new[](size_t,
void* ptr_)
noexcept {
return ptr_; }
160hxinline void*
operator new(size_t,
void* ptr_)
noexcept {
return ptr_; }
161hxinline void*
operator new[](size_t,
void* ptr_)
noexcept {
return ptr_; }
164#if (HX_PROVIDE_NEW_DELETE) != -1
169void operator delete(
void* ptr_)
noexcept;
170void operator delete[](
void* ptr_)
noexcept;
209 return m_initial_allocation_count_;
214 return m_initial_bytes_allocated_;
222 size_t allocation_count_,
size_t bytes_allocated_);
232 size_t m_initial_allocation_count_;
233 size_t m_initial_bytes_allocated_;
245T_*
hxnew(Args_&&... args_)
noexcept {
247 return ::new(hxmalloc_ext(
sizeof(T_),
allocator_, align_)) T_(
static_cast<Args_&&
>(args_)...);
253template <
typename T_>
257 hxfree(
const_cast<void*
>(
static_cast<const void*
>(t_)));
268 template <
typename T_>
272 operator bool(
void)
const {
return true; }
281 template <
typename T_>
285 operator bool(
void)
const {
return false; }
288#if HX_CPLUSPLUS >= 201402L
296 template <
typename T_>
300 constexpr operator bool(
void)
const {
return true; }
325template<
size_t stack_count_>
hxconsteval_delete - A constexpr-compatible deleter that uses delete.
Definition hxmemory_manager.h:292
constexpr void operator()(T *t_) const
Deletes the object using delete.
Definition hxmemory_manager.h:297
hxdefault_delete - A callable that deletes objects of type T using hxdelete.
Definition hxmemory_manager.h:265
void operator()(T *t_) const
Deletes the object using hxdelete.
Definition hxmemory_manager.h:269
hxdo_not_delete - A version of hxdefault_delete that does not delete the object.
Definition hxmemory_manager.h:278
void operator()(T *) const
Does not delete the object.
Definition hxmemory_manager.h:282
hxmemory_manager_stats - The utilization statistics reported by hxmemory_manager_utilization.
Definition hxmemory_manager.h:332
size_t allocator_overflows
Definition hxmemory_manager.h:336
size_t allocations_outstanding
Definition hxmemory_manager.h:334
size_t bytes_outstanding
Definition hxmemory_manager.h:335
friend hxinline void hxsystem_allocator_scope_init_(hxsystem_allocator_scope *scope_, size_t allocation_count_, size_t bytes_allocated_)
hxattr_nodiscard size_t get_initial_bytes_allocated(void) const
Gets the number of bytes allocated when this scope was entered.
Definition hxmemory_manager.h:213
hxattr_nodiscard size_t get_current_bytes_allocated(void) const
Gets the total number of bytes allocated outstanding for this memory allocator.
hxattr_nodiscard size_t get_initial_allocation_count(void) const
Gets the number of allocations made when this scope was entered.
Definition hxmemory_manager.h:208
hxattr_nodiscard size_t get_current_allocation_count(void) const
Gets the total number of allocations outstanding for this memory allocator.
hxsystem_allocator_scope(hxsystem_allocator_t allocator_) hxattr_noexcept
Constructor: Sets the current memory allocator to the specified ID.
~hxsystem_allocator_scope(void) hxattr_noexcept
Destructor restores the stored previous memory manager allocator ID.
@ hxsystem_allocator_stack_0
hxsystem_allocator_stack_0 - Temporary stacks.
Definition hxmemory_manager.h:88
@ hxsystem_allocator_heap
hxsystem_allocator_heap - OS heap with alignment.
Definition hxmemory_manager.h:82
@ hxsystem_allocator_current
hxsystem_allocator_current - Use current allocation scope.
Definition hxmemory_manager.h:80
@ hxsystem_allocator_permanent
hxsystem_allocator_permanent - Contiguous allocations that must not be freed.
Definition hxmemory_manager.h:85
HX_C_BEGIN_ typedef unsigned int hxalignment_t
hxalignment_t - A positive integer power of 2 for aligning allocations.
Definition hxmemory_manager.h:62
int hxsystem_allocator_t
hxsystem_allocator_t - This is extendable by the application.
Definition hxmemory_manager.h:75
hxinline char * hxstring_duplicate(const char *s_)
hxstring_duplicate - Add default args to C interface.
Definition hxmemory_manager.h:147
HX_C_END_ hxinline void * hxmalloc(size_t size_, hxsystem_allocator_t allocator_, hxalignment_t alignment_=hxalignment)
hxmalloc - Add hxmalloc_ext args to hxmalloc C interface.
Definition hxmemory_manager.h:139
void hxfree(void *ptr_) hxattr_noexcept hxattr_hot
hxfree - Frees memory previously allocated with hxmalloc or hxmalloc_ext.
void hxdelete(T *t_) noexcept
hxdelete - Deletes an object of type T and frees its memory using the memory manager.
Definition hxmemory_manager.h:254
hxattr_noexcept hxsystem_allocator_t allocator_
Definition hxmemory_manager.h:120
T * hxnew(Args_ &&... args_) noexcept
hxnew<T, allocator, align>(...) - Allocates and constructs an object of type T using an optional memo...
Definition hxmemory_manager.h:245
hxattr_noexcept hxsystem_allocator_t hxalignment_t alignment_
Definition hxmemory_manager.h:121
void hxmemory_manager_allocate_stacks(const size_t *sizes_, size_t stack_count_) hxattr_cold
hxmemory_manager_allocate_stacks - Allocates the runtime temporary stacks.
constexpr hxalignment_t hxalignment
hxalignment - The default alignment.
Definition hxmemory_manager.h:67
hxmemory_manager_stats hxmemory_manager_utilization(bool stacks_only_, bool log_) hxattr_cold
hxmemory_manager_utilization - Returns the utilization statistics of the memory manager.
#define hxinline
hxinline - Force a function to be inlined into its callers.
Definition hxsettings.h:125
#define hxattr_noexcept
hxattr_noexcept - Use gcc/clang nothrow attribute.
Definition hxsettings.h:102
#define hxattr_allocator(...)
hxattr_allocator - Mark allocator/deallocator pairs for static analysis.
Definition hxsettings.h:79
#define hxattr_nonnull(...)
hxattr_nonnull - Indicates that a function has args that should not be null.
Definition hxsettings.h:106
#define hxattr_nodiscard
hxattr_nodiscard - Indicates the caller should not discard the return value.
Definition hxsettings.h:98
#define hxattr_cold
hxattr_cold - Optimize a function for size.
Definition hxsettings.h:86
#define hxattr_hot
hxattr_hot - Optimize a function more aggressively.
Definition hxsettings.h:94