7 #include "../lib/vstguibase.h" 15 static void* allocate (
size_t size) {
return std::malloc (size); }
16 static void deallocate (
void* ptr,
size_t size) { std::free (ptr); }
20 template <
typename T,
typename Allocator = MallocAllocator>
25 Malloc (
size_t objectCount) : count (objectCount)
28 allocate (objectCount);
33 buffer = other.buffer;
35 other.buffer =
nullptr;
41 ~
Malloc () { deallocate (); }
43 T*
get () {
return buffer; }
44 const T*
get ()
const {
return buffer; }
45 size_t size ()
const {
return count; }
47 void allocate (
size_t objectCount)
52 buffer =
static_cast<T*
> (Allocator::allocate (objectCount *
sizeof (T)));
60 Allocator::deallocate (buffer, count *
sizeof (T));
Definition: customcontrols.cpp:8