/src/poco/Foundation/include/Poco/BufferAllocator.h
Line | Count | Source |
1 | | // |
2 | | // BufferAllocator.h |
3 | | // |
4 | | // Library: Foundation |
5 | | // Package: Streams |
6 | | // Module: BufferAllocator |
7 | | // |
8 | | // Definition of the BufferAllocator class. |
9 | | // |
10 | | // Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. |
11 | | // and Contributors. |
12 | | // |
13 | | // SPDX-License-Identifier: BSL-1.0 |
14 | | // |
15 | | |
16 | | |
17 | | #ifndef Foundation_BufferAllocator_INCLUDED |
18 | | #define Foundation_BufferAllocator_INCLUDED |
19 | | |
20 | | |
21 | | #include "Poco/Foundation.h" |
22 | | #include <ios> |
23 | | #include <cstddef> |
24 | | |
25 | | |
26 | | namespace Poco { |
27 | | |
28 | | |
29 | | template <typename ch> |
30 | | class BufferAllocator |
31 | | /// The BufferAllocator used if no specific |
32 | | /// BufferAllocator has been specified. |
33 | | { |
34 | | public: |
35 | | using char_type = ch; |
36 | | |
37 | | static char_type* allocate(std::streamsize size) |
38 | 236k | { |
39 | 236k | return new char_type[static_cast<std::size_t>(size)]; |
40 | 236k | } |
41 | | |
42 | | static void deallocate(char_type* ptr, std::streamsize /*size*/) noexcept |
43 | 236k | { |
44 | 236k | delete [] ptr; |
45 | 236k | } |
46 | | }; |
47 | | |
48 | | |
49 | | } // namespace Poco |
50 | | |
51 | | |
52 | | #endif // Foundation_BufferAllocator_INCLUDED |