allocators.cpp 613 B

12345678910111213141516171819202122
  1. #include "Allocator.h"
  2. #include "MallocAllocator.h"
  3. #include <cstdio>
  4. #include "Assert.h"
  5. using namespace crown;
  6. int main()
  7. {
  8. MallocAllocator malloc_allocator;
  9. char* char_buffer = (char*)malloc_allocator.allocate(128);
  10. CE_ASSERT(malloc_allocator.allocated_size() >= 128, "Allocated size differs from requested size");
  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. //CE_ASSERT(malloc_allocator.get_allocated_size() == 0);
  15. }