ReactOS 0.4.16-dev-125-g798ea90
Pool Class Reference

#include <bufpool.h>

Collaboration diagram for Pool:

Public Member Functions

 Pool (int, int, const char *)
 
 ~Pool (void)
 
voidnew_buffer (void)
 
void free_buffer (void *)
 
void clear (void)
 

Protected Types

enum  Magic { is_allocated = 0xf3a1 , is_free = 0xf1a2 }
 

Protected Attributes

Bufferfreelist
 
charblocklist [NBLOCKS]
 
int nextblock
 
charcurblock
 
int buffersize
 
int nextsize
 
int nextfree
 
int initsize
 
const charname
 
Magic magic
 

Private Member Functions

void grow (void)
 

Detailed Description

Definition at line 50 of file bufpool.h.

Member Enumeration Documentation

◆ Magic

enum Pool::Magic
protected
Enumerator
is_allocated 
is_free 

Definition at line 70 of file bufpool.h.

70{ is_allocated = 0xf3a1, is_free = 0xf1a2 };
@ is_allocated
Definition: bufpool.h:70
@ is_free
Definition: bufpool.h:70

Constructor & Destructor Documentation

◆ Pool()

Pool::Pool ( int  _buffersize,
int  initpoolsize,
const char n 
)

Definition at line 49 of file bufpool.cc.

50{
51 if((unsigned)_buffersize < sizeof(Buffer))
52 buffersize = sizeof(Buffer);
53 else
54 buffersize = _buffersize;
55 initsize = initpoolsize * buffersize;
57 name = n;
59 nextblock = 0;
60 curblock = 0;
61 freelist = 0;
62 nextfree = 0;
63 for (int i = 0; i < NBLOCKS; i++) {
64 blocklist[i] = 0;
65 }
66}
#define NBLOCKS
Definition: bufpool.h:43
Definition: bufpool.h:45
int nextfree
Definition: bufpool.h:68
char * blocklist[NBLOCKS]
Definition: bufpool.h:63
int initsize
Definition: bufpool.h:69
Buffer * freelist
Definition: bufpool.h:62
int buffersize
Definition: bufpool.h:66
Magic magic
Definition: bufpool.h:72
int nextsize
Definition: bufpool.h:67
char * curblock
Definition: bufpool.h:65
int nextblock
Definition: bufpool.h:64
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: name.c:39

◆ ~Pool()

Pool::~Pool ( void  )

Definition at line 73 of file bufpool.cc.

74{
75 assert( (this != 0) && (magic == is_allocated) );
76
77 while( nextblock ) {
78 delete [] blocklist[--nextblock];
80 }
81 magic = is_free;
82}
#define assert(x)
Definition: debug.h:53

Member Function Documentation

◆ clear()

void Pool::clear ( void  )

Definition at line 100 of file bufpool.cc.

101{
102 assert( (this != 0) && (magic == is_allocated) );
103
104 while( nextblock ) {
105 delete [] blocklist[--nextblock];
106 blocklist[nextblock] = 0;
107 }
108 curblock = 0;
109 freelist = 0;
110 nextfree = 0;
111 if( nextsize > initsize )
112 nextsize /= 2;
113}

Referenced by Subdivider::clear(), and Maplist::freeMaps().

◆ free_buffer()

void Pool::free_buffer ( void b)
inline

Definition at line 81 of file bufpool.h.

82{
83 assert( (this != 0) && (magic == is_allocated) );
84
85 /* add buffer to singly connected free list */
86
87 ((Buffer *) b)->next = freelist;
88 freelist = (Buffer *) b;
89}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

◆ grow()

void Pool::grow ( void  )
private

Definition at line 85 of file bufpool.cc.

86{
87 assert( (this != 0) && (magic == is_allocated) );
88 curblock = new char[nextsize];
91 nextsize *= 2;
92}

Referenced by new_buffer().

◆ new_buffer()

void * Pool::new_buffer ( void  )
inline

Definition at line 98 of file bufpool.h.

99{
100 void *buffer;
101
102 assert( (this != 0) && (magic == is_allocated) );
103
104 /* find free buffer */
105
106 if( freelist ) {
107 buffer = (void *) freelist;
109 } else {
110 if( ! nextfree )
111 grow( );
113 buffer = (void *) (curblock + nextfree);
114 }
115 return buffer;
116}
Buffer * next
Definition: bufpool.h:47
void grow(void)
Definition: bufpool.cc:85
GLuint buffer
Definition: glext.h:5915

Member Data Documentation

◆ blocklist

char* Pool::blocklist[NBLOCKS]
protected

Definition at line 63 of file bufpool.h.

Referenced by clear(), grow(), Pool(), and ~Pool().

◆ buffersize

int Pool::buffersize
protected

Definition at line 66 of file bufpool.h.

Referenced by new_buffer(), and Pool().

◆ curblock

char* Pool::curblock
protected

Definition at line 65 of file bufpool.h.

Referenced by clear(), grow(), new_buffer(), and Pool().

◆ freelist

Buffer* Pool::freelist
protected

Definition at line 62 of file bufpool.h.

Referenced by clear(), free_buffer(), new_buffer(), and Pool().

◆ initsize

int Pool::initsize
protected

Definition at line 69 of file bufpool.h.

Referenced by clear(), and Pool().

◆ magic

Magic Pool::magic
protected

Definition at line 72 of file bufpool.h.

Referenced by clear(), free_buffer(), grow(), new_buffer(), Pool(), and ~Pool().

◆ name

const char* Pool::name
protected

Definition at line 71 of file bufpool.h.

◆ nextblock

int Pool::nextblock
protected

Definition at line 64 of file bufpool.h.

Referenced by clear(), grow(), Pool(), and ~Pool().

◆ nextfree

int Pool::nextfree
protected

Definition at line 68 of file bufpool.h.

Referenced by clear(), grow(), new_buffer(), and Pool().

◆ nextsize

int Pool::nextsize
protected

Definition at line 67 of file bufpool.h.

Referenced by clear(), grow(), and Pool().


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