-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyMain.cpp
More file actions
41 lines (34 loc) · 1.04 KB
/
myMain.cpp
File metadata and controls
41 lines (34 loc) · 1.04 KB
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
#include "memManager.h"
void main(void){
memManager mem;
char *abc = (char *)mem.memalloc(10);
strcpy(abc, "HOW is");
char *abc2 = (char *)mem.memalloc(5);
strcpy(abc2, "ab");
char *abc3 = (char *)mem.memalloc(10);
strcpy(abc3, "woe");
char *abc4 = (char *)mem.memalloc(4);
strcpy(abc4, "CD");
std::cout <<endl << "CURRENT meory contents are as follow" <<endl;
mem.printMem();
std::cout <<endl << "Deleting 3rd allocation" <<endl;
mem.free(abc3);
char *abc6 = (char *)mem.memalloc(10);
if(abc6!=NULL){
strcpy(abc6, "*What In** ");
}
std::cout <<endl << "CURRENT meory contents are as follow" <<endl;
mem.printMem();
std::cout <<endl << "Deleting 2nd allocation" <<endl;
mem.free(abc2);
std::cout <<endl << "Following cannot be allocated if the previous two free mem are not merged" <<endl;
char *abc5 = (char *)mem.memalloc(15);
if(abc5!=NULL){
strcpy(abc5, "*How Are** ");
}
std::cout <<endl << "CURRENT meory contents are as follow" <<endl;
mem.printMem();
mem.free(abc);
mem.free(abc4);
mem.free(abc5);
}//end of main