mirror of
https://github.com/devkitPro/wut.git
synced 2026-12-04 23:10:51 -06:00
Some checks failed
C/C++ CI / ubuntu-latest (push) Has been cancelled
* Add and apply some allocation-related attributes `WUT_ALLOC_SIZE` was left off `MEMAllocFromExpHeapEx` because the allocated region may be resized via `MEMResizeForMBlockExpHeap`, but is always accessed via the same pointer. Some functions had to have the free and allocate function order swapped because the two-parameter `malloc` attribute relies on declaration order * Add attrs to `MEMAllocFromDefaultHeapFn` and `MEMAllocFromDefaultHeapExFn` * Add attrs to `MEMAllocFromBlockHeapEx`, `MEMAllocFromBlockHeapAt` and `MEMAllocFromFrmHeapEx` * whoops * Add attrs to `MEMAllocFromUnitHeap` * Formatting * Fix doxygen expansion
70 lines
1.4 KiB
C
70 lines
1.4 KiB
C
#pragma once
|
|
#include <wut.h>
|
|
#include "memheap.h"
|
|
|
|
/**
|
|
* \defgroup coreinit_unitheap Unit Heap
|
|
* \ingroup coreinit
|
|
* @{
|
|
*/
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct MEMUnitHeap MEMUnitHeap;
|
|
typedef struct MEMUnitHeapFreeBlock MEMUnitHeapFreeBlock;
|
|
|
|
struct MEMUnitHeapFreeBlock
|
|
{
|
|
MEMUnitHeapFreeBlock *next;
|
|
};
|
|
WUT_CHECK_OFFSET(MEMUnitHeapFreeBlock, 0x00, next);
|
|
WUT_CHECK_SIZE(MEMUnitHeapFreeBlock, 0x04);
|
|
|
|
struct WUT_PACKED MEMUnitHeap
|
|
{
|
|
MEMHeapHeader header;
|
|
MEMUnitHeapFreeBlock *freeBlocks;
|
|
uint32_t blockSize;
|
|
};
|
|
WUT_CHECK_OFFSET(MEMUnitHeap, 0x00, header);
|
|
WUT_CHECK_OFFSET(MEMUnitHeap, 0x40, freeBlocks);
|
|
WUT_CHECK_OFFSET(MEMUnitHeap, 0x44, blockSize);
|
|
WUT_CHECK_SIZE(MEMUnitHeap, 0x48);
|
|
|
|
MEMHeapHandle
|
|
MEMCreateUnitHeapEx(void *heap,
|
|
uint32_t size,
|
|
uint32_t blockSize,
|
|
int32_t alignment,
|
|
uint16_t flags);
|
|
|
|
void *
|
|
MEMDestroyUnitHeap(MEMHeapHandle heap);
|
|
|
|
void
|
|
MEMFreeToUnitHeap(MEMHeapHandle heap,
|
|
void *block);
|
|
|
|
void *
|
|
MEMAllocFromUnitHeap(MEMHeapHandle heap)
|
|
WUT_MALLOC WUT_FREED_BY(MEMFreeToUnitHeap, 2);
|
|
|
|
void
|
|
MEMiDumpUnitHeap(MEMHeapHandle heap);
|
|
|
|
uint32_t
|
|
MEMCountFreeBlockForUnitHeap(MEMHeapHandle heap);
|
|
|
|
uint32_t
|
|
MEMCalcHeapSizeForUnitHeap(uint32_t blockSize,
|
|
uint32_t count,
|
|
int32_t alignment);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
/** @} */
|