1 /*---------------------------------------------------------------------------* 2 Project: MEM library 3 File: allocator.h 4 Programmers: Makoto Takano 5 6 Copyright 2005 Nintendo. All rights reserved. 7 8 These coded instructions, statements, and computer programs contain 9 proprietary information of Nintendo of America Inc. and/or Nintendo 10 Company Ltd., and are protected by Federal copyright law. They may 11 not be disclosed to third parties or copied or duplicated in any form, 12 in whole or in part, without the prior written consent of Nintendo. 13 *---------------------------------------------------------------------------*/ 14 15 #ifndef MEM_ALLOCATOR_H__ 16 #define MEM_ALLOCATOR_H__ 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 23 #include <revolution/mem/heapCommon.h> 24 25 /* ======================================================================== 26 Type Definitions 27 ======================================================================== */ 28 29 typedef struct MEMAllocator MEMAllocator; 30 31 typedef void* (*MEMFuncAllocatorAlloc)( MEMAllocator* pAllocator, u32 size ); 32 33 typedef void (*MEMFuncAllocatorFree) ( MEMAllocator* pAllocator, void* memBlock ); 34 35 typedef struct MEMAllocatorFunc MEMAllocatorFunc; 36 37 struct MEMAllocatorFunc 38 { 39 MEMFuncAllocatorAlloc pfAlloc; 40 MEMFuncAllocatorFree pfFree; 41 }; 42 43 struct MEMAllocator 44 { 45 MEMAllocatorFunc const * pFunc; 46 void* pHeap; 47 u32 heapParam1; 48 u32 heapParam2; 49 }; 50 51 52 /* ======================================================================== 53 Function Prototype 54 ======================================================================== */ 55 56 void* MEMAllocFromAllocator( MEMAllocator* pAllocator, u32 size ); 57 58 void MEMFreeToAllocator ( MEMAllocator* pAllocator, void* memBlock ); 59 60 void MEMInitAllocatorForExpHeap( 61 MEMAllocator* pAllocator, 62 MEMHeapHandle heap, 63 int alignment ); 64 65 void MEMInitAllocatorForFrmHeap( 66 MEMAllocator* pAllocator, 67 MEMHeapHandle heap, 68 int alignment ); 69 70 void MEMInitAllocatorForUnitHeap( MEMAllocator* pAllocator, MEMHeapHandle heap ); 71 72 void MEMInitAllocatorForOSHeap ( MEMAllocator* pAllocator, OSHeapHandle heap ); 73 74 75 #ifdef __cplusplus 76 } /* extern "C"*/ 77 #endif 78 79 /* MEM_ALLOCATOR_H__*/ 80 #endif 81