Use enums instead of defines in memheap.h

This commit is contained in:
James Benton 2016-07-23 11:08:00 +01:00
parent 29b6d586e6
commit d02bdf6e35
3 changed files with 19 additions and 14 deletions

View File

@ -14,8 +14,9 @@ extern "C" {
typedef enum MEMFrameHeapFreeMode typedef enum MEMFrameHeapFreeMode
{ {
MEM_FRAME_HEAP_FREE_FROM_BOTTOM = 1 << 0, MEM_FRAME_HEAP_FREE_HEAD = 1 << 0,
MEM_FRAME_HEAP_FREE_FROM_TOP = 1 << 1, MEM_FRAME_HEAP_FREE_TAIL = 1 << 1,
MEM_FRAME_HEAP_FREE_ALL = MEM_FRAME_HEAP_FREE_HEAD | MEM_FRAME_HEAP_FREE_TAIL,
} MEMFrameHeapFreeMode; } MEMFrameHeapFreeMode;
typedef struct MEMFrameHeap MEMFrameHeap; typedef struct MEMFrameHeap MEMFrameHeap;
@ -48,7 +49,7 @@ CHECK_OFFSET(MEMFrameHeap, 0x48, previousState);
CHECK_SIZE(MEMFrameHeap, 0x4C); CHECK_SIZE(MEMFrameHeap, 0x4C);
MEMFrameHeap * MEMFrameHeap *
MEMCreateFrmHeapEx(MEMFrameHeap *heap, MEMCreateFrmHeapEx(void *heap,
uint32_t size, uint32_t size,
uint32_t flags); uint32_t flags);

View File

@ -24,21 +24,26 @@ typedef enum MEMHeapFillType
MEM_HEAP_FILL_TYPE_FREED = 2, MEM_HEAP_FILL_TYPE_FREED = 2,
} MEMHeapFillType; } MEMHeapFillType;
#define MEM_BLOCK_HEAP_TAG 0x424C4B48u typedef enum MEMHeapTag
#define MEM_EXPANDED_HEAP_TAG 0x45585048u {
#define MEM_FRAME_HEAP_TAG 0x46524D48u MEM_BLOCK_HEAP_TAG = 0x424C4B48u,
#define MEM_UNIT_HEAP_TAG 0x554E5448u MEM_EXPANDED_HEAP_TAG = 0x45585048u,
#define MEM_USER_HEAP_TAG 0x55535248u MEM_FRAME_HEAP_TAG = 0x46524D48u,
MEM_UNIT_HEAP_TAG = 0x554E5448u,
MEM_USER_HEAP_TAG = 0x55535248u,
} MEMHeapTag;
typedef enum MEMHeapFlags
#define MEM_HEAP_FLAG_ZERO_ALLOCATED (1 << 0) {
#define MEM_HEAP_FLAG_DEBUG_MODE (1 << 1) MEM_HEAP_FLAG_ZERO_ALLOCATED = 1 << 0,
#define MEM_HEAP_FLAG_USE_LOCK (1 << 2) MEM_HEAP_FLAG_DEBUG_MODE = 1 << 1,
MEM_HEAP_FLAG_USE_LOCK = 1 << 2,
} MEMHeapFlags;
struct MEMHeapHeader struct MEMHeapHeader
{ {
//! Tag indicating which type of heap this is //! Tag indicating which type of heap this is
uint32_t tag; MEMHeapTag tag;
//! Link for list this heap is in //! Link for list this heap is in
MEMMemoryLink link; MEMMemoryLink link;

View File

@ -19,7 +19,6 @@ struct MEMMemoryLink
void *prev; void *prev;
void *next; void *next;
}; };
CHECK_OFFSET(MEMMemoryLink, 0x0, prev); CHECK_OFFSET(MEMMemoryLink, 0x0, prev);
CHECK_OFFSET(MEMMemoryLink, 0x4, next); CHECK_OFFSET(MEMMemoryLink, 0x4, next);
CHECK_SIZE(MEMMemoryLink, 0x8); CHECK_SIZE(MEMMemoryLink, 0x8);