comparison 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
comparison
equal deleted inserted replaced
5:e9bdc899bcd1 6:94464f59a33c
12 12
13 #include <malloc.h> 13 #include <malloc.h>
14 #include <inttypes.h> 14 #include <inttypes.h>
15 #include "VMS_primitive_data_types.h" 15 #include "VMS_primitive_data_types.h"
16 16
17 #define SMALL_CHUNK_SIZE 32
18 #define SMALL_CHUNK_COUNT 4
19 #define LOWER_BOUND 128
20 #define CHUNK_INCREASE_RATE 1.25
21
22 #define LOG54 0.096910013
23 #define LOG128 2.10720997
24
17 typedef struct _MallocProlog MallocProlog; 25 typedef struct _MallocProlog MallocProlog;
18 26
19 struct _MallocProlog 27 struct _MallocProlog
20 { 28 {
21 MallocProlog *nextChunkInFreeList; 29 MallocProlog *nextChunkInFreeList;
22 MallocProlog *prevChunkInFreeList; 30 MallocProlog *prevChunkInFreeList;
23 MallocProlog *nextHigherInMem; 31 MallocProlog *nextHigherInMem;
24 MallocProlog *nextLowerInMem; 32 MallocProlog *nextLowerInMem;
25 }; 33 };
26 //MallocProlog 34 //MallocProlog
35
36 typedef struct MallocArrays MallocArrays;
37
38 struct MallocArrays
39 {
40 MallocProlog **smallChunks;
41 MallocProlog **bigChunks;
42 uint32 containerCount;
43 };
44 //MallocArrays
27 45
28 typedef struct 46 typedef struct
29 { 47 {
30 MallocProlog *firstChunkInFreeList; 48 MallocProlog *firstChunkInFreeList;
31 int32 numInList; //TODO not used 49 int32 numInList; //TODO not used
50 */ 68 */
51 void 69 void
52 VMS__free_in_ext( void *ptrToFree ); 70 VMS__free_in_ext( void *ptrToFree );
53 71
54 72
55 MallocProlog * 73 MallocArrays *
56 VMS_ext__create_free_list(); 74 VMS_ext__create_free_list();
57 75
58 void 76 void
59 VMS_ext__free_free_list( MallocProlog *freeListHead ); 77 VMS_ext__free_free_list( MallocProlog *freeListHead );
60 78