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
|
diff -Naur muse-0.6.2-orig/memory.cpp muse-0.6.2/memory.cpp
--- muse-0.6.2-orig/memory.cpp 2003-10-29 10:04:59.000000000 +0000
+++ muse-0.6.2/memory.cpp 2004-06-29 18:52:16.634314333 +0000
@@ -45,7 +45,7 @@
void Pool::grow(int idx)
{
- int esize = (idx+1) * sizeof(int);
+ int esize = (idx+1) * sizeof(void*); //just guessing here
Chunk* n = new Chunk;
n->next = chunks[idx];
diff -Naur muse-0.6.2-orig/memory.h muse-0.6.2/memory.h
--- muse-0.6.2-orig/memory.h 2004-06-29 18:54:53.416816939 +0000
+++ muse-0.6.2/memory.h 2004-06-29 18:53:55.567225085 +0000
@@ -24,11 +24,11 @@
Verweis* next;
};
struct Chunk {
- enum { size = 4 * 1024 };
+ enum { size = sizeof(void*) * 1024 };
Chunk* next;
char mem[size];
};
- enum { dimension = 8 };
+ enum { dimension = 4*sizeof(void*) }; //maybe 2*sizeof(void*) was meant .. nobody knows
Chunk* chunks[dimension];
Verweis* head[dimension];
Pool(Pool&);
@@ -48,10 +48,10 @@
inline void* Pool::alloc(size_t n)
{
- int idx = ((n + sizeof(int) - 1) / sizeof(int)) - 1;
+ int idx = ((n + sizeof(void*) - 1) / sizeof(void*)) - 1; // what does that formular mean?
if (idx >= dimension) {
- printf("panic: alloc %lu\n", n);
- exit(-1);
+ printf("Using std-allocator %lu characters requested",n);
+ return ::operator new(n);
}
if (head[idx] == 0)
grow(idx);
@@ -66,10 +66,10 @@
inline void Pool::free(void* b, size_t n)
{
- int idx = ((n + sizeof(int) - 1) / sizeof(int)) - 1;
+ int idx = ((n + sizeof(void*) - 1) / sizeof(void*)) - 1;
if (idx >= dimension) {
- printf("panic: alloc %lu\n", n);
- exit(-1);
+ printf("Using std-deallocator %lu characters to be freed",n);
+ return ::operator delete(b);
}
Verweis* p = static_cast<Verweis*>(b);
p->next = head[idx];
|