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
26namespace Poco {
27
28
29template <typename ch>
30class BufferAllocator
31 /// The BufferAllocator used if no specific
32 /// BufferAllocator has been specified.
33{
34public:
35 typedef ch char_type;
36
37 static char_type* allocate(std::streamsize size)
38 {
39 return new char_type[static_cast<std::size_t>(size)];
40 }
41
42 static void deallocate(char_type* ptr, std::streamsize /*size*/) throw()
43 {
44 delete [] ptr;
45 }
46};
47
48
49} // namespace Poco
50
51
52#endif // Foundation_BufferAllocator_INCLUDED
53