1 /* 2 * Copyright (c) 2013-2018 Ali Mashtizadeh 3 * All rights reserved. 4 */ 5 6 #include <stdarg.h> 7 #include <stdint.h> 8 9 #include <kassert.h> 10 11 typedef struct TLSFBlock 12 { 13 struct TLSFBlock *prevBlock; 14 uint64_t size; 15 // Only valid for free blocks 16 struct TLSFBlock *prev; 17 struct TLSFBlock *next; 18 } TLSFBlock; 19 20 typedef struct Heap 21 { 22 uint64_t magic; 23 24 // Lock 25 26 // Debug statistics 27 uint64_t poolSize; 28 uint64_t poolAllocs; 29 30 // Free list 31 uint32_t flVector; 32 uint32_t slVector[FL_SIZE]; 33 struct TLSFBlock *blocks[SL_SIZE][FL_SIZE]; 34 } Heap; 35 36 Heap* Malloc_Create()37Malloc_Create() 38 { 39 } 40 41 void Malloc_Destroy(Heap * heap)42Malloc_Destroy(Heap *heap) 43 { 44 } 45 46 void* Malloc_Alloc(Heap * heap,uint64_t len)47Malloc_Alloc(Heap *heap, uint64_t len) 48 { 49 } 50 51 void Malloc_Free(Heap * heap,void * buf)52Malloc_Free(Heap *heap, void *buf) 53 { 54 } 55 56 bool Malloc_Realloc(Heap * heap,void * buf,uint64_t newlen)57Malloc_Realloc(Heap *heap, void *buf, uint64_t newlen) 58 { 59 } 60 61