| 366 | } |
| 367 | |
| 368 | void DmaMemoryPool::Free(void *ptr) { |
| 369 | // allow null pointers |
| 370 | if (!ptr) { |
| 371 | return; |
| 372 | } |
| 373 | |
| 374 | const auto &it = alloced_.find(ptr); |
| 375 | CHECK(it != alloced_.end()) << "Unknown pointer " << ptr; |
| 376 | const size_t size = (*it).second; |
| 377 | AddRegion(reinterpret_cast<uintptr_t>(ptr), size); |
| 378 | alloced_.erase(it); |
| 379 | total_free_bytes_ += size; |
| 380 | } |
| 381 | |
| 382 | std::string DmaMemoryPool::Dump() { |
| 383 | std::ostringstream out; |