| 106 | } |
| 107 | |
| 108 | bool ScriptHeap::release(void* ptr) |
| 109 | { |
| 110 | if (!ptr) { |
| 111 | return false; |
| 112 | } |
| 113 | Deleter deleter = nullptr; |
| 114 | { |
| 115 | std::lock_guard<std::mutex> lock(mMutex); |
| 116 | auto it = mBlocks.find(ptr); |
| 117 | if (it == mBlocks.end()) { |
| 118 | return false; |
| 119 | } |
| 120 | deleter = it->second; |
| 121 | mBlocks.erase(it); |
| 122 | } |
| 123 | // Outside the lock: a deleter is free() or a C++ destructor, neither of |
| 124 | // which needs the map, and both of which can be slow. |
| 125 | deleter(ptr); |
| 126 | return true; |
| 127 | } |
| 128 | |
| 129 | bool ScriptHeap::owns(void* ptr) const |
| 130 | { |
no test coverage detected