forked from HaoLi1996/p2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_memory.c
47 lines (37 loc) · 1.29 KB
/
my_memory.c
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
// Include files
#include <stdio.h>
#include <stdlib.h>
#define N_OBJS_PER_SLAB 64
// Functional prototypes
void setup( int malloc_type, int mem_size, void* start_of_memory );
void *my_malloc( int size );
void my_free( void *ptr );
////////////////////////////////////////////////////////////////////////////
//
// Function : setup
// Description : initialize the memory allocation system
//
// Inputs : malloc_type - the type of memory allocation method to be used [0..3] where
// (0) Buddy System
// (1) Slab Allocation
void setup( int malloc_type, int mem_size, void* start_of_memory ){
}
////////////////////////////////////////////////////////////////////////////
//
// Function : my_malloc
// Description : allocates memory segment using specified allocation algorithm
//
// Inputs : size - size in bytes of the memory to be allocated
// Outputs : -1 - if request cannot be made with the maximum mem_size requirement
void *my_malloc( int size ){
}
////////////////////////////////////////////////////////////////////////////
//
// Function : my_free
// Description : deallocated the memory segment being passed by the pointer
//
// Inputs : ptr - pointer to the memory segment to be free'd
// Outputs :
void my_free( void *ptr )
{
}