-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemfitHelpers.H
75 lines (53 loc) · 1.46 KB
/
memfitHelpers.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* ===========================================================================
*
* memfitHelpers.H --
*
*
* Wolfram Schenck <[email protected]>
*
*
* 1.0 / 17. Nov 15 (ws)
* - from scratch
*
*
* ===========================================================================
*/
#ifndef __MEM_FIT_HELPERS_H__
#define __MEM_FIT_HELPERS_H__
#include <stdio.h>
#include <stdlib.h>
#include <vector>
// ---------------------------------------------------------------------------
#define VERBOSE 0
// ---------------------------------------------------------------------------
struct memBlock {
unsigned address;
unsigned size;
};
extern std::vector<memBlock> freeList;
extern std::vector<memBlock> allocList;
// ---------------------------------------------------------------------------
void
initHeap( unsigned minAddress, unsigned heapSize );
void
printList( const char *header, const std::vector<memBlock> blockList );
void
randomFree();
unsigned
allocBlock( unsigned index, unsigned blockSize );
unsigned
meldFreeBlocks();
int
freeBlock( unsigned address );
// ---------------------------------------------------------------------------
unsigned
firstFitAlloc( unsigned blockSize );
unsigned
nextFitAlloc( unsigned blockSize );
unsigned
bestFitAlloc( unsigned blockSize );
unsigned
worstFitAlloc( unsigned blockSize );
int
writeOutFile(const unsigned fits[4], const unsigned alloc_max, const unsigned trials);
#endif // __MEM_FIT_HELPERS_H__