annotate vmalloc.h @ 101:ca154ebe2b6c

Basic malloc without small chunks
author Merten Sach <msach@mailbox.tu-berlin.de>
date Tue, 02 Aug 2011 15:44:28 +0200
parents 521c75d64cef
children def70e32cf2c
rev   line source
Me@50 1 /*
Me@50 2 * Copyright 2009 OpenSourceCodeStewardshipFoundation.org
Me@50 3 * Licensed under GNU General Public License version 2
Me@50 4 *
Me@50 5 * Author: seanhalle@yahoo.com
Me@50 6 *
Me@50 7 * Created on November 14, 2009, 9:07 PM
Me@50 8 */
Me@50 9
Me@65 10 #ifndef _VMALLOC_H
Me@65 11 #define _VMALLOC_H
Me@65 12
Me@50 13 #include <malloc.h>
msach@76 14 #include <inttypes.h>
Me@50 15 #include "VMS_primitive_data_types.h"
Me@50 16
msach@101 17 #define SMALL_CHUNK_SIZE 32
msach@101 18 #define SMALL_CHUNK_COUNT 4
msach@101 19 #define LOWER_BOUND 128
msach@101 20 #define CHUNK_INCREASE_RATE 1.25
msach@101 21
msach@101 22 #define LOG54 0.096910013
msach@101 23 #define LOG128 2.10720997
msach@101 24
Me@50 25 typedef struct _MallocProlog MallocProlog;
Me@50 26
Me@50 27 struct _MallocProlog
Me@50 28 {
Me@50 29 MallocProlog *nextChunkInFreeList;
Me@50 30 MallocProlog *prevChunkInFreeList;
Me@50 31 MallocProlog *nextHigherInMem;
Me@50 32 MallocProlog *nextLowerInMem;
Me@50 33 };
Me@50 34 //MallocProlog
msach@101 35
msach@101 36 typedef struct MallocArrays MallocArrays;
msach@101 37
msach@101 38 struct MallocArrays
msach@101 39 {
msach@101 40 MallocProlog **smallChunks;
msach@101 41 MallocProlog **bigChunks;
msach@101 42 uint32 containerCount;
msach@101 43 };
msach@101 44 //MallocArrays
Me@50 45
Me@50 46 typedef struct
Me@50 47 {
Me@50 48 MallocProlog *firstChunkInFreeList;
msach@76 49 int32 numInList; //TODO not used
Me@50 50 }
Me@50 51 FreeListHead;
Me@50 52
Me@50 53 void *
msach@76 54 VMS__malloc( size_t sizeRequested );
Me@50 55
msach@78 56 void *
msach@78 57 VMS__malloc_aligned( size_t sizeRequested );
msach@78 58
Me@50 59 void
Me@50 60 VMS__free( void *ptrToFree );
Me@50 61
Me@53 62 /*Allocates memory from the external system -- higher overhead
Me@53 63 */
Me@53 64 void *
msach@76 65 VMS__malloc_in_ext( size_t sizeRequested );
Me@53 66
Me@53 67 /*Frees memory that was allocated in the external system -- higher overhead
Me@53 68 */
Me@53 69 void
Me@53 70 VMS__free_in_ext( void *ptrToFree );
Me@53 71
Me@53 72
msach@101 73 MallocArrays *
Me@53 74 VMS_ext__create_free_list();
Me@50 75
Me@50 76 void
Me@50 77 VMS_ext__free_free_list( MallocProlog *freeListHead );
Me@65 78
Me@65 79 #endif