Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
view 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 |
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
22 #define LOG54 0.096910013
23 #define LOG128 2.10720997
25 typedef struct _MallocProlog MallocProlog;
27 struct _MallocProlog
28 {
29 MallocProlog *nextChunkInFreeList;
30 MallocProlog *prevChunkInFreeList;
31 MallocProlog *nextHigherInMem;
32 MallocProlog *nextLowerInMem;
33 };
34 //MallocProlog
36 typedef struct MallocArrays MallocArrays;
38 struct MallocArrays
39 {
40 MallocProlog **smallChunks;
41 MallocProlog **bigChunks;
42 uint32 containerCount;
43 };
44 //MallocArrays
46 typedef struct
47 {
48 MallocProlog *firstChunkInFreeList;
49 int32 numInList; //TODO not used
50 }
51 FreeListHead;
53 void *
54 VMS__malloc( size_t sizeRequested );
56 void *
57 VMS__malloc_aligned( size_t sizeRequested );
59 void
60 VMS__free( void *ptrToFree );
62 /*Allocates memory from the external system -- higher overhead
63 */
64 void *
65 VMS__malloc_in_ext( size_t sizeRequested );
67 /*Frees memory that was allocated in the external system -- higher overhead
68 */
69 void
70 VMS__free_in_ext( void *ptrToFree );
73 MallocArrays *
74 VMS_ext__create_free_list();
76 void
77 VMS_ext__free_free_list( MallocProlog *freeListHead );
79 #endif
