mirror of
https://github.com/Andreabont/CppExperiments.git
synced 2025-07-15 19:21:16 +00:00
33 lines
613 B
C++
33 lines
613 B
C++
#include <iostream>
|
|
#include <vector>
|
|
|
|
#include "PoolAllocator.h"
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
PoolAllocator<int, 10> pool;
|
|
|
|
std::cout << "Test allocate..." << std::endl;
|
|
|
|
int* i = pool.allocate();
|
|
int* j = pool.allocate();
|
|
|
|
*i = 1;
|
|
*j = 2;
|
|
|
|
std::cout << "Test dump..." << std::endl;
|
|
pool.dump();
|
|
|
|
std::cout << "Test deallocate..." << std::endl;
|
|
pool.deallocate(i);
|
|
pool.deallocate(j);
|
|
|
|
std::cout << "Test bad alloc..." << std::endl;
|
|
|
|
for(int i = 0; i < 11; i++) {
|
|
pool.allocate();
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|