-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmymalloc.h
51 lines (42 loc) · 1019 Bytes
/
mymalloc.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
/**
mymalloc.h - main program header
Rutgers CS 01:198:214 Systems Programming
Professor John-Austen Francisco
Authors: Anthony Siluk & Alexander Goodkind
Due: 10/15/2019
*/
#ifndef _MYMALLOC_H
#define _MYMALLOC_H
#define malloc( x ) mymalloc( ( x ) , __FILE__, __LINE__ )
#define free( x ) myfree( ( x ) , __FILE__ , __LINE__ )
#define HEAP_SIZE 4096
/**
we use this node struct as the metadata
char inUse: 't' = true
'f' = false
*/
typedef struct _node {
unsigned short blockSize;
char inUse;
} node;
/**
boolean is just false = 0, and true != 0 (1)
for readibility sake
*/
typedef enum _bool {
false = 0,
true = 1
} bool;
/* main functionality */
void* mymalloc (size_t, char*, int);
void myfree (void*, char*, int);
/* required functions */
char* findOpenNode (size_t);
void combineFreeBlocks (void);
void* splitBlock (char*, size_t);
/* helpers */
char* getNext(char*);
bool isInUse(node*);
char inUseBoolToChar(bool);
bool inUseCharToBool(char);
#endif /* _MYMALLOC_H */