blob: 6cd49c26451b47e3f7d43bdd6344464dc820bf12 (
plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#ifndef __objectlist_h__
#define __objectlist_h__
#include "arraylist.h"
#include "holder.h"
#define INVALID_COMPRESSEDSTACK_INDEX ((DWORD)-1)
#ifdef _DEBUG
#define FREE_LIST_SIZE 128
#else
#define FREE_LIST_SIZE 1024
#endif
class ObjectList
{
public:
class Iterator
{
friend class ObjectList;
protected:
ArrayList::Iterator _iter;
public:
PTR_VOID GetElement()
{
LIMITED_METHOD_CONTRACT;
PTR_VOID ptr = _iter.GetElement();
if (((DWORD)(size_t)(dac_cast<TADDR>(ptr)) & 0x1) == 0)
{
return ptr;
}
else
{
return NULL;
}
}
DWORD GetIndex()
{
LIMITED_METHOD_CONTRACT;
return _iter.GetIndex();
}
BOOL Next()
{
LIMITED_METHOD_CONTRACT;
return _iter.Next();
}
};
ObjectList() DAC_EMPTY();
DWORD AddToList( PVOID ptr );
void RemoveFromList( PVOID ptr );
void RemoveFromList( DWORD index, PVOID ptr );
PVOID Get( DWORD index );
ObjectList::Iterator Iterate()
{
LIMITED_METHOD_CONTRACT;
ObjectList::Iterator i;
i._iter = this->allEntries_.Iterate();
return i;
}
private:
ArrayList allEntries_;
DWORD freeIndexHead_;
Crst listLock_;
};
class UnsynchronizedBlockAllocator
{
public:
UnsynchronizedBlockAllocator( size_t blockSize );
~UnsynchronizedBlockAllocator( void );
PVOID Allocate( size_t size );
private:
ArrayList blockList_;
size_t blockSize_;
size_t offset_;
DWORD index_;
};
#endif // __objectlist_h__
|