2021-06-27 21:25:29 +00:00
/***
Copyright ( C ) 2021 J Reece Wilson ( a / k / a " Reece " ) . All rights reserved .
File : Heap . hpp
Date : 2021 - 6 - 9
Author : Reece
* * */
# pragma once
namespace Aurora : : Memory
{
2024-01-16 21:11:08 +00:00
struct ProxyHeap ;
2024-03-19 15:47:42 +00:00
static const AuUInt8 kHeapSize = 128 ;
static const AuUInt8 kHeap2Size = 255 ;
2024-01-16 21:11:08 +00:00
2024-07-13 02:07:02 +00:00
template < class T >
struct CppHeapWrapper ;
2022-07-21 09:59:02 +00:00
struct Heap
2021-06-27 21:25:29 +00:00
{
2022-07-21 09:59:02 +00:00
virtual AuSPtr < Heap > AllocateDivision ( AuUInt32 heap , AuUInt32 alignment = 32 ) = 0 ;
2024-01-16 21:11:08 +00:00
virtual Types : : size_t GetChunkSize ( const void * pHead ) = 0 ;
2022-12-08 19:34:15 +00:00
virtual HeapStats & GetStats ( ) = 0 ;
2024-03-04 04:44:49 +00:00
virtual void WalkHeap ( bool ( * fCallback ) ( void * , void * ) , void * pSecondArg ) = 0 ;
2021-06-27 21:25:29 +00:00
2024-03-19 15:47:42 +00:00
// Potentially slower, zero allocate
2021-06-27 21:25:29 +00:00
template < typename T = void * >
2024-03-19 15:47:42 +00:00
T ZAlloc ( Types : : size_t uLength )
2021-06-27 21:25:29 +00:00
{
2024-03-19 15:47:42 +00:00
if constexpr ( AuIsVoid_v < AuRemovePointer_t < T > > )
{
return reinterpret_cast < T > ( _ZAlloc ( uLength ) ) ;
}
else
{
return reinterpret_cast < T > ( _ZAlloc ( uLength , alignof ( AuRemovePointer_t < T > ) ) ) ;
}
2021-06-27 21:25:29 +00:00
}
template < typename T = void * >
2024-03-19 15:47:42 +00:00
T ZAlloc ( Types : : size_t uLength , Types : : size_t uAlignment )
2021-06-27 21:25:29 +00:00
{
2024-03-19 15:47:42 +00:00
return reinterpret_cast < T > ( _ZAlloc ( uLength , uAlignment ) ) ;
2021-06-27 21:25:29 +00:00
}
template < typename T >
T * ZAlloc ( )
{
2024-03-19 15:47:42 +00:00
return reinterpret_cast < T * > ( _ZAlloc ( sizeof ( T ) , alignof ( T ) ) ) ;
2021-06-27 21:25:29 +00:00
}
template < typename T >
2024-03-19 15:47:42 +00:00
T * NewArray ( Types : : size_t uLength )
2021-06-27 21:25:29 +00:00
{
2024-03-19 15:47:42 +00:00
return ZAlloc < T * > ( uLength * sizeof ( T ) , alignof ( T ) ) ;
2021-06-27 21:25:29 +00:00
}
template < typename T >
2024-03-19 15:47:42 +00:00
T * NewArray ( Types : : size_t uLength , Types : : size_t uAlignment )
2021-06-27 21:25:29 +00:00
{
2024-03-19 15:47:42 +00:00
return ZAlloc < T * > ( uLength * sizeof ( T ) , uAlignment ) ;
2021-06-27 21:25:29 +00:00
}
/// Fast, unsafe alloc
template < typename T = void * >
2024-03-19 15:47:42 +00:00
T FAlloc ( Types : : size_t uLength )
2021-06-27 21:25:29 +00:00
{
2024-03-19 15:47:42 +00:00
if constexpr ( AuIsVoid_v < AuRemovePointer_t < T > > )
{
return reinterpret_cast < T > ( _FAlloc ( uLength ) ) ;
}
else
{
return reinterpret_cast < T > ( _FAlloc ( uLength , alignof ( AuRemovePointer_t < T > ) ) ) ;
}
2021-06-27 21:25:29 +00:00
}
template < typename T = void * >
2024-03-19 15:47:42 +00:00
T FAlloc ( Types : : size_t uLength , Types : : size_t uAlignment )
2021-06-27 21:25:29 +00:00
{
2024-03-19 15:47:42 +00:00
return reinterpret_cast < T > ( _FAlloc ( uLength , uAlignment ) ) ;
2021-06-27 21:25:29 +00:00
}
template < typename T >
2024-03-19 15:47:42 +00:00
T * FAlloc ( )
2021-06-27 21:25:29 +00:00
{
2024-03-19 15:47:42 +00:00
return reinterpret_cast < T * > ( _FAlloc ( sizeof ( T ) , alignof ( T ) ) ) ;
2021-06-27 21:25:29 +00:00
}
2024-03-19 15:47:42 +00:00
// Reallocs
2021-06-27 21:25:29 +00:00
template < typename T >
2024-03-19 15:47:42 +00:00
T ZRealloc ( T pHead , Types : : size_t uLength )
2021-06-27 21:25:29 +00:00
{
2024-03-19 15:47:42 +00:00
if constexpr ( AuIsVoid_v < AuRemovePointer_t < T > > )
{
return reinterpret_cast < T > ( _ZRealloc ( reinterpret_cast < void * > ( pHead ) , uLength ) ) ;
}
else
{
return reinterpret_cast < T > ( _ZRealloc ( reinterpret_cast < void * > ( pHead ) , uLength , alignof ( AuRemovePointer_t < T > ) ) ) ;
}
}
template < typename T >
T ZRealloc ( T pHead , Types : : size_t uLength , Types : : size_t uAlignment )
{
return reinterpret_cast < T > ( _ZRealloc ( reinterpret_cast < void * > ( pHead ) , uLength , uAlignment ) ) ;
2021-06-27 21:25:29 +00:00
}
template < typename T >
2024-03-19 15:47:42 +00:00
T FRealloc ( T pHead , Types : : size_t uLength )
2021-06-27 21:25:29 +00:00
{
2024-03-19 15:47:42 +00:00
if constexpr ( AuIsVoid_v < AuRemovePointer_t < T > > )
{
return reinterpret_cast < T > ( _FRealloc ( reinterpret_cast < void * > ( pHead ) , uLength ) ) ;
}
else
{
return reinterpret_cast < T > ( _FRealloc ( reinterpret_cast < void * > ( pHead ) , uLength , alignof ( AuRemovePointer_t < T > ) ) ) ;
}
2021-06-27 21:25:29 +00:00
}
template < typename T >
2024-03-19 15:47:42 +00:00
T FRealloc ( T pHead , Types : : size_t uLength , Types : : size_t uAlignment )
2021-06-27 21:25:29 +00:00
{
2024-03-19 15:47:42 +00:00
return reinterpret_cast < T > ( _FRealloc ( reinterpret_cast < void * > ( pHead ) , uLength , uAlignment ) ) ;
2021-06-27 21:25:29 +00:00
}
2024-03-19 15:47:42 +00:00
// Free
2021-06-27 21:25:29 +00:00
template < typename T >
2024-01-16 21:11:08 +00:00
void Free ( T pHead )
2021-06-27 21:25:29 +00:00
{
2024-01-16 21:11:08 +00:00
_Free ( reinterpret_cast < void * > ( pHead ) ) ;
2021-06-27 21:25:29 +00:00
}
2024-01-18 12:17:01 +00:00
protected :
template < typename T >
static void DeleteThat ( T * pThat )
{
static const auto kAlignment = AuMax ( alignof ( T ) , sizeof ( void * ) ) ;
2024-03-17 13:16:43 +00:00
if constexpr ( AuIsClass_v < T > & &
2024-03-19 09:58:00 +00:00
! AuIsTriviallyDestructible_v < T > )
2024-01-18 12:17:01 +00:00
{
pThat - > ~ T ( ) ;
}
auto & pHeap = * ( Heap * * ) ( ( ( char * ) pThat ) - kAlignment ) ;
pHeap - > _Free ( & pHeap ) ;
}
template < typename T >
static void DeleteThatArray ( T * pThat )
{
static const auto kAlignment = AuMax ( alignof ( T ) , sizeof ( void * ) * 2 ) ;
auto pVoids = ( void * * ) ( ( ( char * ) pThat ) - kAlignment ) ;
auto pHeap = ( Heap * ) pVoids [ 0 ] ;
2024-03-19 15:47:42 +00:00
auto uLength = ( AuUInt ) pVoids [ 1 ] ;
2024-01-18 12:17:01 +00:00
2024-03-17 13:16:43 +00:00
if constexpr ( AuIsClass_v < T > & &
2024-03-19 09:58:00 +00:00
! AuIsTriviallyDestructible_v < T > )
2024-01-18 12:17:01 +00:00
{
2024-03-19 15:47:42 +00:00
for ( AU_ITERATE_N ( i , uLength ) )
2024-01-18 12:17:01 +00:00
{
auto & refElement = pThat [ i ] ;
refElement . ~ T ( ) ;
}
}
pHeap - > _Free ( pVoids ) ;
}
2024-02-15 01:10:23 +00:00
template < typename T , typename Z >
static void DeleteThatCastedOnce ( T * pThat )
{
2024-03-17 13:16:43 +00:00
static const auto kAlignment = AuMax ( alignof ( Z ) , sizeof ( void * ) ) ;
2024-02-15 01:10:23 +00:00
auto pBaseClass = AuStaticCast < Z > ( pThat ) ;
2024-03-17 13:16:43 +00:00
if constexpr ( AuIsClass_v < Z > & &
2024-03-19 09:58:00 +00:00
! AuIsTriviallyDestructible_v < Z > )
2024-02-15 01:10:23 +00:00
{
pBaseClass - > ~ Z ( ) ;
}
auto & pHeap = * ( Heap * * ) ( ( ( char * ) pBaseClass ) - kAlignment ) ;
pHeap - > _Free ( & pHeap ) ;
}
2024-01-18 12:17:01 +00:00
template < typename T >
static void RetardedSpecWrittenByRetards ( T * pThat )
{
}
public :
2022-12-08 19:34:15 +00:00
template < class T , class . . . Args >
2023-12-01 06:50:39 +00:00
AuSPtr < T > NewClass ( Args & & . . . args )
2022-12-08 19:34:15 +00:00
{
2024-01-16 21:11:08 +00:00
static const auto kAlignment = AuMax ( alignof ( T ) , sizeof ( void * ) ) ;
AuUInt8 * pPtr ;
2022-12-08 19:34:15 +00:00
2024-01-18 00:01:00 +00:00
auto pThat = this - > GetSelfReferenceRaw ( ) ;
if ( ! pThat )
{
pThat = this ;
}
2024-03-17 13:16:43 +00:00
if constexpr ( AuIsClass_v < T > & &
2024-03-19 09:58:00 +00:00
! AuIsTriviallyConstructible_v < T , Args . . . > )
2022-12-08 19:34:15 +00:00
{
2024-01-18 00:01:00 +00:00
pPtr = pThat - > FAlloc < AuUInt8 * > ( sizeof ( T ) + kAlignment , kAlignment ) ;
2022-12-08 19:34:15 +00:00
if ( pPtr )
{
2024-02-13 03:18:13 +00:00
new ( pPtr + kAlignment ) T ( AuForward < Args > ( args ) . . . ) ;
2022-12-08 19:34:15 +00:00
}
}
else
{
2024-01-18 00:01:00 +00:00
pPtr = pThat - > ZAlloc < AuUInt8 * > ( sizeof ( T ) + kAlignment , kAlignment ) ;
2022-12-08 19:34:15 +00:00
}
if ( ! pPtr )
{
return { } ;
}
2024-01-18 00:01:00 +00:00
* ( void * * ) pPtr = pThat ;
2024-03-19 15:47:42 +00:00
auto pTThat = ( T * ) ( pPtr + kAlignment ) ;
AUROXTL_COMMODITY_TRY
{
2024-07-13 02:07:02 +00:00
return AuSPtr < T > ( pTThat , & Heap : : DeleteThat < T > , CppHeapWrapper < T > { this } ) ;
2024-03-19 15:47:42 +00:00
}
AUROXTL_COMMODITY_CATCH
{
Heap : : DeleteThat < T > ( pTThat ) ;
return { } ;
}
2022-12-08 19:34:15 +00:00
}
2024-03-19 15:47:42 +00:00
// note: callers can use AuHUPOf_t<Z> pUniquePointer = AuNullHeapPointer<Z>()
2024-01-18 12:17:01 +00:00
2024-03-17 13:16:43 +00:00
template < class T , class Z = T , class . . . Args >
AuUPtr < Z , decltype ( & Heap : : DeleteThat < Z > ) > NewClassUnique ( Args & & . . . args )
2024-01-18 12:17:01 +00:00
{
static const auto kAlignment = AuMax ( alignof ( T ) , sizeof ( void * ) ) ;
AuUInt8 * pPtr ;
auto pThat = this - > GetSelfReferenceRaw ( ) ;
if ( ! pThat )
{
pThat = this ;
}
2024-03-17 13:16:43 +00:00
if constexpr ( AuIsClass_v < T > & &
2024-03-19 09:58:00 +00:00
! AuIsTriviallyConstructible_v < T , Args . . . > )
2024-01-18 12:17:01 +00:00
{
pPtr = pThat - > FAlloc < AuUInt8 * > ( sizeof ( T ) + kAlignment , kAlignment ) ;
if ( pPtr )
{
2024-02-13 03:18:13 +00:00
new ( pPtr + kAlignment ) T ( AuForward < Args > ( args ) . . . ) ;
2024-01-18 12:17:01 +00:00
}
}
else
{
pPtr = pThat - > ZAlloc < AuUInt8 * > ( sizeof ( T ) + kAlignment , kAlignment ) ;
}
if ( ! pPtr )
{
2024-03-17 13:16:43 +00:00
return AuUPtr < Z , decltype ( & Heap : : DeleteThat < Z > ) > ( nullptr , & Heap : : RetardedSpecWrittenByRetards < Z > ) ;
2024-01-18 12:17:01 +00:00
}
* ( void * * ) pPtr = pThat ;
2024-03-17 13:16:43 +00:00
if constexpr ( AuIsSame_v < T , Z > )
{
return AuUPtr < T , decltype ( & Heap : : DeleteThat < T > ) > ( ( T * ) ( pPtr + kAlignment ) , & Heap : : DeleteThat < T > ) ;
}
else
{
return Heap : : CastPointer < Z > ( AuMove ( AuUPtr < T , decltype ( & Heap : : DeleteThat < T > ) > ( ( T * ) ( pPtr + kAlignment ) , & Heap : : DeleteThat < T > ) ) ) ;
}
2024-01-18 12:17:01 +00:00
}
2024-01-16 21:11:08 +00:00
template < class T , class . . . Args >
AuSPtr < T > NewClassArray ( AuUInt uElements , Args & & . . . fillCtr )
2021-06-27 21:25:29 +00:00
{
2024-01-16 21:11:08 +00:00
static const auto kAlignment = AuMax ( alignof ( T ) , sizeof ( void * ) * 2 ) ;
AuUInt8 * pPtr ;
if ( ! uElements )
{
return { } ;
}
2024-01-18 00:01:00 +00:00
auto pThat = this - > GetSelfReferenceRaw ( ) ;
if ( ! pThat )
{
pThat = this ;
}
2024-03-17 13:16:43 +00:00
if constexpr ( AuIsClass_v < T > & &
2024-03-19 09:58:00 +00:00
! AuIsTriviallyConstructible_v < T , Args . . . > )
2024-01-16 21:11:08 +00:00
{
2024-01-18 00:01:00 +00:00
if ( bool ( pPtr = pThat - > FAlloc < AuUInt8 * > ( ( sizeof ( T ) * uElements ) + kAlignment , kAlignment ) ) )
2024-01-16 21:11:08 +00:00
{
for ( AU_ITERATE_N ( i , uElements ) )
{
2024-02-13 03:18:13 +00:00
new ( pPtr + kAlignment + ( sizeof ( T ) * i ) ) T ( AuForward < Args > ( fillCtr ) . . . ) ;
2024-01-16 21:11:08 +00:00
}
}
}
else
{
2024-01-18 00:01:00 +00:00
if ( bool ( pPtr = pThat - > ZAlloc < AuUInt8 * > ( ( sizeof ( T ) * uElements ) + kAlignment , kAlignment ) ) )
2024-01-16 21:11:08 +00:00
{
if constexpr ( sizeof . . . ( Args ) ! = 0 )
{
# if defined(AURT_HEAP_NO_STL)
static_assert ( false ) ;
# else
auto pElements = ( T * ) ( pPtr + kAlignment ) ;
2024-02-13 03:18:13 +00:00
std : : fill ( pElements , pElements + uElements , AuForward < Args > ( fillCtr ) . . . ) ;
2024-01-16 21:11:08 +00:00
# endif
}
}
}
if ( ! pPtr )
{
return { } ;
}
auto pVoids = ( void * * ) pPtr ;
2024-01-18 00:01:00 +00:00
pVoids [ 0 ] = pThat ;
2024-01-16 21:11:08 +00:00
pVoids [ 1 ] = ( void * ) uElements ;
2024-03-19 15:47:42 +00:00
auto pTThat = ( T * ) ( pPtr + kAlignment ) ;
AUROXTL_COMMODITY_TRY
{
2024-07-13 02:07:02 +00:00
return AuSPtr < T > ( pTThat , & Heap : : DeleteThatArray < T > , CppHeapWrapper < T > { this } ) ;
2024-03-19 15:47:42 +00:00
}
AUROXTL_COMMODITY_CATCH
{
Heap : : DeleteThatArray < T > ( pTThat ) ;
return { } ;
}
2021-06-27 21:25:29 +00:00
}
2024-01-19 19:40:38 +00:00
// note: callers can use AuHUPOf_t<T> pUniquePointer = AuNullHeapPointer<T>()
2024-01-18 12:17:01 +00:00
template < class T , class . . . Args >
AuUPtr < T , decltype ( & Heap : : DeleteThat < T > ) > NewClassArrayUnique ( AuUInt uElements , Args & & . . . fillCtr )
{
static const auto kAlignment = AuMax ( alignof ( T ) , sizeof ( void * ) * 2 ) ;
AuUInt8 * pPtr ;
if ( ! uElements )
{
return AuUPtr < T , decltype ( & Heap : : DeleteThat < T > ) > ( nullptr , & Heap : : RetardedSpecWrittenByRetards < T > ) ;
}
auto pThat = this - > GetSelfReferenceRaw ( ) ;
if ( ! pThat )
{
pThat = this ;
}
2024-03-17 13:16:43 +00:00
if constexpr ( AuIsClass_v < T > & &
2024-03-19 09:58:00 +00:00
! AuIsTriviallyConstructible_v < T , Args . . . > )
2024-01-18 12:17:01 +00:00
{
if ( bool ( pPtr = pThat - > FAlloc < AuUInt8 * > ( ( sizeof ( T ) * uElements ) + kAlignment , kAlignment ) ) )
{
for ( AU_ITERATE_N ( i , uElements ) )
{
2024-02-13 03:18:13 +00:00
new ( pPtr + kAlignment + ( sizeof ( T ) * i ) ) T ( AuForward < Args > ( fillCtr ) . . . ) ;
2024-01-18 12:17:01 +00:00
}
}
}
else
{
if ( bool ( pPtr = pThat - > ZAlloc < AuUInt8 * > ( ( sizeof ( T ) * uElements ) + kAlignment , kAlignment ) ) )
{
if constexpr ( sizeof . . . ( Args ) ! = 0 )
{
# if defined(AURT_HEAP_NO_STL)
static_assert ( false ) ;
# else
auto pElements = ( T * ) ( pPtr + kAlignment ) ;
2024-02-13 03:18:13 +00:00
std : : fill ( pElements , pElements + uElements , AuForward < Args > ( fillCtr ) . . . ) ;
2024-01-18 12:17:01 +00:00
# endif
}
}
}
if ( ! pPtr )
{
return AuUPtr < T , decltype ( & Heap : : DeleteThat < T > ) > ( nullptr , & Heap : : RetardedSpecWrittenByRetards < T > ) ;
}
auto pVoids = ( void * * ) pPtr ;
pVoids [ 0 ] = pThat ;
pVoids [ 1 ] = ( void * ) uElements ;
return AuUPtr < T , decltype ( & Heap : : DeleteThat < T > ) > ( ( T * ) ( pPtr + kAlignment ) , & Heap : : DeleteThatArray < T > ) ;
}
2024-01-19 19:40:38 +00:00
template < class T >
cstatic AuUPtr < T , decltype ( & Heap : : DeleteThat < T > ) > NullUniquePointer ( )
{
return AuUPtr < T , decltype ( & Heap : : DeleteThat < T > ) > ( nullptr , & Heap : : RetardedSpecWrittenByRetards < T > ) ;
}
2024-02-14 06:35:43 +00:00
template < class Z , class T >
cstatic AuUPtr < Z , decltype ( & Heap : : DeleteThat < Z > ) > CastPointer ( AuUPtr < T , decltype ( & Heap : : DeleteThat < T > ) > & & pInPointer )
{
if ( ! pInPointer )
{
return NullUniquePointer < Z > ( ) ;
}
2024-02-15 01:10:23 +00:00
else if ( pInPointer . get_deleter ( ) = = & Heap : : DeleteThat < T > )
{
return AuUPtr < Z , decltype ( & Heap : : DeleteThat < Z > ) > ( AuStaticCast < Z > ( pInPointer . release ( ) ) , & Heap : : DeleteThatCastedOnce < Z , T > ) ;
}
2024-02-14 06:35:43 +00:00
else
{
2024-02-15 01:10:23 +00:00
return NullUniquePointer < Z > ( ) ;
2024-02-14 06:35:43 +00:00
}
}
2024-01-18 17:19:35 +00:00
template < typename T >
using HUPOf_t = AuUPtr < T , decltype ( & Heap : : DeleteThat < T > ) > ;
2024-01-16 21:11:08 +00:00
protected :
friend struct ProxyHeap ;
2024-01-27 08:04:29 +00:00
friend struct HeapAccessor ;
2022-01-18 19:31:15 +00:00
2022-12-08 19:34:15 +00:00
virtual AuSPtr < Heap > GetSelfReference ( ) = 0 ; // may return empty/default. not all heaps are sharable.
2024-01-16 21:11:08 +00:00
virtual Heap * GetSelfReferenceRaw ( ) = 0 ;
2022-12-08 19:34:15 +00:00
virtual AU_ALLOC void * _ZAlloc ( Types : : size_t uLength ) = 0 ;
2024-03-19 15:47:42 +00:00
virtual AU_ALLOC void * _ZAlloc ( Types : : size_t uLength , Types : : size_t uAlignment ) = 0 ;
2022-12-08 19:34:15 +00:00
virtual AU_ALLOC void * _FAlloc ( Types : : size_t uLength ) = 0 ;
2024-03-19 15:47:42 +00:00
virtual AU_ALLOC void * _FAlloc ( Types : : size_t uLength , Types : : size_t uAlignment ) = 0 ;
2022-12-08 19:34:15 +00:00
virtual AU_ALLOC void * _ZRealloc ( void * pBase , Types : : size_t uLength , Types : : size_t uAlign ) = 0 ;
virtual AU_ALLOC void * _ZRealloc ( void * pBase , Types : : size_t uLength ) = 0 ;
virtual AU_ALLOC void * _FRealloc ( void * pBase , Types : : size_t uLength , Types : : size_t uAlign ) = 0 ;
virtual AU_ALLOC void * _FRealloc ( void * pBase , Types : : size_t uLength ) = 0 ;
virtual void _Free ( void * pBase ) = 0 ;
2021-06-27 21:25:29 +00:00
} ;
2024-01-27 08:04:29 +00:00
struct HeapAccessor
{
cstatic AuSPtr < Heap > GetSelfReference ( Heap * pHeap )
{
return pHeap - > GetSelfReference ( ) ;
}
cstatic Heap * GetSelfReferenceRaw ( Heap * pHeap )
{
return pHeap - > GetSelfReferenceRaw ( ) ;
}
} ;
2021-06-27 21:25:29 +00:00
/**
2024-03-19 15:47:42 +00:00
* Returns a heap interface backed by the default allocator
*/
2024-02-13 03:18:13 +00:00
AUKN_SHARED_API ( DefaultDiscontiguousHeap , Heap ) ;
inline Heap * GetDefaultDiscontiguousHeap ( )
{
return DefaultDiscontiguousHeapNew ( ) ;
}
inline AuSPtr < Heap > GetDefaultDiscontiguousHeapShared ( )
{
// Might not allocate the control block under some STLs, unlike DefaultDiscontiguousHeapSharedShared() which will generally always allocate a control block under most STLs
return AuUnsafeRaiiToShared ( GetDefaultDiscontiguousHeap ( ) ) ;
}
2021-06-27 21:25:29 +00:00
/**
2024-03-19 15:47:42 +00:00
* Allocates uLength amount of contiguous virtual memory
* @ return a heap backed by uLength bytes of virtual memory
* @ warning the SOO variant cannot guarantee release - on - last - free and will panic if uLength cannot be allocated . Use AllocHeap [ Shared / Unique / New ] ( uLength ) instead .
*/
AUKN_SHARED_SOO2_NCM ( AllocHeap , Heap , kHeapSize , ( ( AuUInt , uLength ) ) , AuUInt uLength ) ;
2024-01-15 12:04:40 +00:00
2024-03-19 15:47:42 +00:00
/**
2024-04-23 23:52:22 +00:00
* @ warning the SOO variant cannot guarantee release - on - last - free and will panic if an invalid memory handle is provided .
2024-03-19 15:47:42 +00:00
*/
AUKN_SHARED_SOO2_NCM ( RequestHeapOfRegion , Heap , kHeapSize , ( ( const MemoryViewWrite & , memory ) ) , const MemoryViewWrite & memory ) ;
2022-01-18 19:31:15 +00:00
2024-04-23 23:52:22 +00:00
/**
* @ warning the SOO variant cannot guarantee release - on - last - free and will panic if an invalid memory handle is provided .
*/
AUKN_SHARED_SOO2_NCM ( RequestHeapOfSharedRegion , Heap , kHeapSize , ( ( const AuSPtr < MemoryViewWrite > & , memory ) ) , const AuSPtr < MemoryViewWrite > & pMemory ) ;
2024-03-19 15:47:42 +00:00
/**
* Proxies an existing heap with encapsulated statistics .
* This is intended for debugging purposes when accurate heap stats of a heap - subset are desired .
* @ warning this heap cannot guarantee release - on - last - free
*/
AUKN_SHARED_SOO2_NCM ( HeapProxy , Heap , kHeap2Size , ( ( const AuSPtr < Heap > & , pHead ) ) , const AuSPtr < Heap > & pHead ) ;
2022-01-18 19:31:15 +00:00
2024-03-19 15:47:42 +00:00
/**
* Proxies an existing heap with encapsulated statistics and leak detector
* This is intended for debugging purposes when accurate heap stats of a heap - subset are desired .
* @ warning this heap cannot guarantee release - on - last - free
2021-06-27 21:25:29 +00:00
*/
2024-03-19 15:47:42 +00:00
AUKN_SHARED_SOO2_NCM ( HeapProxyEx , Heap , kHeap2Size , ( ( const AuSPtr < Heap > & , pHead ) , ( LeakFinderAlloc_f , pfAlloc ) , ( LeakFinderFree_f , pfFree ) ) , const AuSPtr < Heap > & pHead , LeakFinderAlloc_f pfAlloc , LeakFinderFree_f pfFree ) ;
2024-01-19 19:40:38 +00:00
}