ReactOS 0.4.15-dev-7924-g5949c20
FastAllocator Class Reference
Collaboration diagram for FastAllocator:

Classes

struct  Block
 

Public Types

enum  { kBlockCount = 1500 , kMinBlockSize = 48 }
 

Static Public Member Functions

static voidAllocate (size_t s)
 
static bool Free (void *p)
 

Static Public Attributes

static BlockmBlocks
 
static BlockmFree
 
static size_t mUsed
 

Friends

struct Block
 

Detailed Description

Definition at line 112 of file nc_alloc.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kBlockCount 
kMinBlockSize 

Definition at line 142 of file nc_alloc.cpp.

142 {
143 // Number of fast allocation blocks to create.
144 kBlockCount = 1500,
145
146 // You may need to adjust this number for your platform.
147 // A good choice will speed tests. A bad choice will still work.
148 kMinBlockSize = 48
149 };

Member Function Documentation

◆ Allocate()

static void * FastAllocator::Allocate ( size_t  s)
inlinestatic

Definition at line 115 of file nc_alloc.cpp.

115 {
116 void *result = 0;
117
118 if (s <= sizeof(Block)) {
119 if (mFree != 0) {
120 result = mFree;
121 mFree = mFree->next;
122 }
123 else if (mBlocks != 0 && mUsed < kBlockCount) {
124 result = (void*)&mBlocks[mUsed++];
125 }
126 }
127 return result;
128 }
static Block * mBlocks
Definition: nc_alloc.cpp:159
static size_t mUsed
Definition: nc_alloc.cpp:161
static Block * mFree
Definition: nc_alloc.cpp:160
GLdouble s
Definition: gl.h:2039
GLuint64EXT * result
Definition: glext.h:11304

Referenced by AllocateBlock().

◆ Free()

static bool FastAllocator::Free ( void p)
inlinestatic

Definition at line 130 of file nc_alloc.cpp.

130 {
131 Block* b = (Block*)p;
132 if (mBlocks == 0 || b < mBlocks || b >= mBlocks + kBlockCount)
133 return false;
134 b->next = mFree;
135 mFree = b;
136 return true;
137 }
friend struct Block
Definition: nc_alloc.cpp:140
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLfloat GLfloat p
Definition: glext.h:8902
#define b
Definition: ke_i.h:79

Referenced by operator delete().

Friends And Related Function Documentation

◆ Block

friend struct Block
friend

Definition at line 140 of file nc_alloc.cpp.

Member Data Documentation

◆ mBlocks

FastAllocator::Block * FastAllocator::mBlocks
static
Initial value:

Definition at line 159 of file nc_alloc.cpp.

Referenced by Allocate(), and Free().

◆ mFree

FastAllocator::Block * FastAllocator::mFree
static

Definition at line 160 of file nc_alloc.cpp.

Referenced by Allocate(), and Free().

◆ mUsed

size_t FastAllocator::mUsed
static

Definition at line 161 of file nc_alloc.cpp.

Referenced by Allocate().


The documentation for this class was generated from the following file: