| 1793 | } |
| 1794 | |
| 1795 | class CustomAllocator : public ntc::IAllocator |
| 1796 | { |
| 1797 | public: |
| 1798 | void* Allocate(size_t size) override |
| 1799 | { |
| 1800 | void* ptr = malloc(size); |
| 1801 | // printf("Allocating %zu bytes at %p.\n", size, ptr); |
| 1802 | m_bytesAllocated += size; |
| 1803 | return ptr; |
| 1804 | } |
| 1805 | |
| 1806 | void Deallocate(void* ptr, size_t size) override |
| 1807 | { |
| 1808 | if (!ptr) |
| 1809 | return; |
| 1810 | // printf("Deallocating %zu bytes at %p.\n", size, ptr); |
| 1811 | m_bytesAllocated -= size; |
| 1812 | free(ptr); |
| 1813 | } |
| 1814 | |
| 1815 | int64_t GetBytesAllocated() const |
| 1816 | { |
| 1817 | return m_bytesAllocated; |
| 1818 | } |
| 1819 | |
| 1820 | private: |
| 1821 | int64_t m_bytesAllocated = 0; |
| 1822 | }; |
| 1823 | |
| 1824 | |
| 1825 | int main(int argc, const char** argv) |
nothing calls this directly
no outgoing calls
no test coverage detected