2
0

allocators.cpp 560 B

12345678910111213141516171819202122
  1. #include "Allocator.h"
  2. #include "MallocAllocator.h"
  3. #include <cstdio>
  4. #include <cassert>
  5. using namespace crown;
  6. int main()
  7. {
  8. MallocAllocator malloc_allocator;
  9. char* char_buffer = (char*)malloc_allocator.allocate(128);
  10. assert(malloc_allocator.allocated_size() >= 128);
  11. printf("MallocAllocator::get_allocated_size(): %d\n", malloc_allocator.allocated_size());
  12. malloc_allocator.deallocate(char_buffer);
  13. printf("MallocAllocator::get_allocated_size(): %d\n", malloc_allocator.allocated_size());
  14. //assert(malloc_allocator.get_allocated_size() == 0);
  15. }