FEI Package Browser (Single Doxygen Collection)
Version of the Day
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
base
fei_Pool.cpp
Go to the documentation of this file.
1
/*--------------------------------------------------------------------*/
2
/* Copyright 2005 Sandia Corporation. */
3
/* Under the terms of Contract DE-AC04-94AL85000, there is a */
4
/* non-exclusive license for use of this work by or on behalf */
5
/* of the U.S. Government. Export of this program may require */
6
/* a license from the United States Government. */
7
/*--------------------------------------------------------------------*/
8
9
#include "
fei_macros.hpp
"
10
#include "
fei_Pool.hpp
"
11
12
fei_Pool::fei_Pool
(
unsigned
int
sz)
13
: chunks(NULL),
14
esize(sz<sizeof(
Link
) ? sizeof(
Link
) : sz),
15
head(NULL)
16
{
17
}
18
19
fei_Pool::~fei_Pool
()
20
{
21
//free all chunks
22
Chunk
*
n
=
chunks
;
23
while
(n) {
24
Chunk
* p = n;
25
n = n->
next
;
26
delete
p;
27
}
28
}
29
30
void
31
fei_Pool::grow
()
32
{
33
//allocate new chunk, organize it as a linked list of elements of size 'esize'
34
Chunk
*
n
=
new
Chunk
;
35
n->
next
=
chunks
;
36
chunks
= n;
37
38
const
int
nelem =
Chunk::size
/
esize
;
39
char
* start = n->
mem
;
40
char
* last = &start[ (nelem-1)*
esize
];
41
for
(
char
* p=start; p<last; p+=
esize
) {
42
reinterpret_cast<
Link
*
>
(p)->next = reinterpret_cast<Link*>(p+
esize
);
43
}
44
reinterpret_cast<
Link
*
>
(last)->next = NULL;
45
head
=
reinterpret_cast<
Link
*
>
(start);
46
}
47
fei_Pool::grow
void grow()
Definition:
fei_Pool.cpp:31
fei_Pool::Chunk::mem
char mem[size]
Definition:
fei_Pool.hpp:41
fei_Pool::~fei_Pool
~fei_Pool()
Definition:
fei_Pool.cpp:19
fei_Pool::head
Link * head
Definition:
fei_Pool.hpp:47
fei_Pool::Chunk::next
Chunk * next
Definition:
fei_Pool.hpp:42
fei_Pool::Link
Definition:
fei_Pool.hpp:33
fei_Pool.hpp
fei_Pool::fei_Pool
fei_Pool(unsigned int n)
Definition:
fei_Pool.cpp:12
fei_Pool::esize
const unsigned int esize
Definition:
fei_Pool.hpp:46
fei_Pool::chunks
Chunk * chunks
Definition:
fei_Pool.hpp:45
fei_Pool::Chunk::size
Definition:
fei_Pool.hpp:40
fei_macros.hpp
n
int n
fei_Pool::Chunk
Definition:
fei_Pool.hpp:36
Generated on Fri Sep 1 2023 07:58:31 for FEI Package Browser (Single Doxygen Collection) by
1.8.5