Me@50: /* Me@50: * Copyright 2009 OpenSourceCodeStewardshipFoundation.org Me@50: * Licensed under GNU General Public License version 2 Me@50: * Me@50: * Author: seanhalle@yahoo.com Me@50: * Me@50: * Created on November 14, 2009, 9:07 PM Me@50: */ Me@50: Me@65: #ifndef _VMALLOC_H Me@65: #define _VMALLOC_H Me@65: Me@50: #include msach@76: #include Me@50: #include "VMS_primitive_data_types.h" Me@50: msach@101: #define SMALL_CHUNK_SIZE 32 msach@101: #define SMALL_CHUNK_COUNT 4 msach@101: #define LOWER_BOUND 128 msach@101: #define CHUNK_INCREASE_RATE 1.25 msach@102: #define MAX_SMALL_CHUNKS 20 msach@102: #define SMALL_CHUNKS_ALLOCATION 5 msach@101: msach@118: #define LOG54 0.3219280948873623 msach@118: #define LOG128 7 msach@101: Me@50: typedef struct _MallocProlog MallocProlog; Me@50: Me@50: struct _MallocProlog Me@50: { Me@50: MallocProlog *nextChunkInFreeList; Me@50: MallocProlog *prevChunkInFreeList; Me@50: MallocProlog *nextHigherInMem; Me@50: MallocProlog *nextLowerInMem; Me@50: }; Me@50: //MallocProlog msach@101: msach@101: typedef struct MallocArrays MallocArrays; msach@101: msach@101: struct MallocArrays msach@101: { msach@101: MallocProlog **smallChunks; msach@101: MallocProlog **bigChunks; msach@116: uint64 bigChunksSearchVector[2]; msach@102: void *memSpace; msach@101: uint32 containerCount; msach@101: }; msach@101: //MallocArrays Me@50: Me@50: typedef struct Me@50: { Me@50: MallocProlog *firstChunkInFreeList; msach@76: int32 numInList; //TODO not used Me@50: } Me@50: FreeListHead; Me@50: Me@50: void * msach@76: VMS__malloc( size_t sizeRequested ); Me@50: msach@78: void * msach@78: VMS__malloc_aligned( size_t sizeRequested ); msach@78: Me@50: void Me@50: VMS__free( void *ptrToFree ); Me@50: Me@53: /*Allocates memory from the external system -- higher overhead Me@53: */ Me@53: void * msach@76: VMS__malloc_in_ext( size_t sizeRequested ); Me@53: Me@53: /*Frees memory that was allocated in the external system -- higher overhead Me@53: */ Me@53: void Me@53: VMS__free_in_ext( void *ptrToFree ); Me@53: Me@53: msach@101: MallocArrays * Me@53: VMS_ext__create_free_list(); Me@50: Me@50: void msach@102: VMS_ext__free_free_list(MallocArrays *freeLists ); Me@65: Me@65: #endif