BufferAllocator.h 911 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #ifndef Foundation_BufferAllocator_INCLUDED
  16. #define Foundation_BufferAllocator_INCLUDED
  17. #include "Poco/Foundation.h"
  18. #include <ios>
  19. #include <cstddef>
  20. namespace Poco {
  21. template <typename ch>
  22. class BufferAllocator
  23. /// The BufferAllocator used if no specific
  24. /// BufferAllocator has been specified.
  25. {
  26. public:
  27. typedef ch char_type;
  28. static char_type* allocate(std::streamsize size)
  29. {
  30. return new char_type[static_cast<std::size_t>(size)];
  31. }
  32. static void deallocate(char_type* ptr, std::streamsize /*size*/) throw()
  33. {
  34. delete [] ptr;
  35. }
  36. };
  37. } // namespace Poco
  38. #endif // Foundation_BufferAllocator_INCLUDED