-
Notifications
You must be signed in to change notification settings - Fork 0
/
Framis.cpp
67 lines (67 loc) · 1.43 KB
/
Framis.cpp
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
//#include<iostream>
//#include <fstream>
//#include <iostream>
//#include <new>
//using namespace std;
//ofstream out("Framis.txt");
//class Framis{
// enum {sz=10};
// char c[sz];
// static unsigned char pool[];
// static bool alloc_map[];
//public:
// enum {psize=100};
// Framis(){out<<"Framis() \n";}
// ~Framis(){out<<"~Framis()...";}
// void *operator new (size_t ) throw (bad_alloc);
// void operator delete (void *);
//};
//unsigned char Framis::pool[psize*sizeof(Framis)];
//bool Framis::alloc_map[psize];
//void * Framis::operator new(size_t )throw (bad_alloc){
// for (int i=0;i<psize;i++)
//
// if (!alloc_map[i])
// {
// out<<"Using block"<<i<<"......";
// alloc_map[i]=true;
// return pool+(i*sizeof(Framis));
//
// }
//
// out<<"out of memory"<<endl;//
// throw bad_alloc();
//}
//void Framis::operator delete(void *m){
// if(!m) return ;
// unsigned long block=(unsigned long)m-(unsigned long)pool;
// block /=sizeof(Framis);
// out<<"freeing block"<<block<<endl;
// alloc_map[block]=false;
//}
//int main()
//{
// Framis*f[Framis::psize];
// try
// {
// for (int i=0;i<Framis::psize;i++)
//
// f[i]=(Framis*)new Framis;
// new Framis;
//
// }
// catch (bad_alloc)
// {
// cerr<<"Out of memory!"<<endl;
//
// }
// delete f[10];
// f[10]=0;
// Framis*x=new Framis;
// delete x;
// for (int j=0;j<Framis::psize;j++)
// {
// delete f[j];
// }
//
//}