view vmalloc.h @ 102:def70e32cf2c

Malloc with easy shave off
author Merten Sach <msach@mailbox.tu-berlin.de>
date Wed, 03 Aug 2011 13:23:32 +0200
parents ca154ebe2b6c
children 62c59f2ac9f1
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 void *memSpace;
46 uint32 containerCount;
47 };
48 //MallocArrays
50 typedef struct
51 {
52 MallocProlog *firstChunkInFreeList;
53 int32 numInList; //TODO not used
54 }
55 FreeListHead;
57 void *
58 VMS__malloc( size_t sizeRequested );
60 void *
61 VMS__malloc_aligned( size_t sizeRequested );
63 void
64 VMS__free( void *ptrToFree );
66 /*Allocates memory from the external system -- higher overhead
67 */
68 void *
69 VMS__malloc_in_ext( size_t sizeRequested );
71 /*Frees memory that was allocated in the external system -- higher overhead
72 */
73 void
74 VMS__free_in_ext( void *ptrToFree );
77 MallocArrays *
78 VMS_ext__create_free_list();
80 void
81 VMS_ext__free_free_list(MallocArrays *freeLists );
83 #endif