Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
view vmalloc.h @ 116:35547e66b971
malloc: multiple small chunk allocation
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Mon, 29 Aug 2011 17:09:00 +0200 |
| parents | 62c59f2ac9f1 |
| children | 07e679ee2095 |
line source
1 /*
2 * Copyright 2009 OpenSourceCodeStewardshipFoundation.org
3 * Licensed under GNU General Public License version 2
4 *
5 * Author: seanhalle@yahoo.com
6 *
7 * Created on November 14, 2009, 9:07 PM
8 */
10 #ifndef _VMALLOC_H
11 #define _VMALLOC_H
13 #include <malloc.h>
14 #include <inttypes.h>
15 #include "VMS_primitive_data_types.h"
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 #define MAX_SMALL_CHUNKS 20
22 #define SMALL_CHUNKS_ALLOCATION 5
24 #define LOG54 0.096910013
25 #define LOG128 2.10720997
27 typedef struct _MallocProlog MallocProlog;
29 struct _MallocProlog
30 {
31 MallocProlog *nextChunkInFreeList;
32 MallocProlog *prevChunkInFreeList;
33 MallocProlog *nextHigherInMem;
34 MallocProlog *nextLowerInMem;
35 };
36 //MallocProlog
38 typedef struct MallocArrays MallocArrays;
40 struct MallocArrays
41 {
42 MallocProlog **smallChunks;
43 uint32 smallChunkCount[SMALL_CHUNK_COUNT];
44 MallocProlog **bigChunks;
45 uint64 bigChunksSearchVector[2];
46 void *memSpace;
47 uint32 containerCount;
48 };
49 //MallocArrays
51 typedef struct
52 {
53 MallocProlog *firstChunkInFreeList;
54 int32 numInList; //TODO not used
55 }
56 FreeListHead;
58 void *
59 VMS__malloc( size_t sizeRequested );
61 void *
62 VMS__malloc_aligned( size_t sizeRequested );
64 void
65 VMS__free( void *ptrToFree );
67 /*Allocates memory from the external system -- higher overhead
68 */
69 void *
70 VMS__malloc_in_ext( size_t sizeRequested );
72 /*Frees memory that was allocated in the external system -- higher overhead
73 */
74 void
75 VMS__free_in_ext( void *ptrToFree );
78 MallocArrays *
79 VMS_ext__create_free_list();
81 void
82 VMS_ext__free_free_list(MallocArrays *freeLists );
84 #endif
