CppServer
1.0.5.0
C++ Server Library
Loading...
Searching...
No Matches
include
server
asio
memory.inl
Go to the documentation of this file.
1
9
namespace
CppServer
{
10
namespace
Asio {
11
12
inline
void
*
HandlerStorage::allocate
(
size_t
size
)
13
{
14
// Check if the storage is not already used and has enough capacity
15
if
(!_in_use && (
size
<
sizeof
(_storage)))
16
{
17
_in_use =
true
;
18
return
&_storage;
19
}
20
21
// Otherwise allocate memory in the heap
22
return ::operator
new
(
size
);
23
}
24
25
inline
void
HandlerStorage::deallocate
(
void
*
ptr
)
26
{
27
// Free storage if memory block was allocated from it
28
if
(
ptr
== &_storage)
29
{
30
_in_use =
false
;
31
return
;
32
}
33
34
// Otherwise free memory in the heap
35
::operator
delete
(
ptr
);
36
}
37
38
template
<
typename
THandler>
39
inline
AllocateHandler<THandler>
make_alloc_handler
(
HandlerStorage
&
storage
,
THandler
handler
)
40
{
41
return
AllocateHandler<THandler>
(
storage
,
handler
);
42
}
43
44
}
// namespace Asio
45
}
// namespace CppServer
CppServer::Asio::AllocateHandler
Asio allocate handler wrapper.
Definition
memory.h:133
CppServer::Asio::HandlerStorage
Asio handler storage.
Definition
memory.h:27
CppServer::Asio::HandlerStorage::deallocate
void deallocate(void *ptr)
Deallocate memory buffer.
Definition
memory.inl:25
CppServer::Asio::HandlerStorage::allocate
void * allocate(size_t size)
Allocate memory buffer.
Definition
memory.inl:12
CppServer::Asio::make_alloc_handler
AllocateHandler< THandler > make_alloc_handler(HandlerStorage &storage, THandler handler)
Helper function to wrap a handler object to add custom allocation.
Definition
memory.inl:39
CppServer
C++ Server project definitions.
Definition
asio.h:56
Generated by
1.9.8