| 67 | // STL clear()/reserve(0) does not always free internal memory allocated |
| 68 | // This function uses swap/destructor to ensure the internal memory is freed. |
| 69 | template<class T> void STLClearObject(T* obj) { |
| 70 | T tmp; |
| 71 | tmp.swap(*obj); |
| 72 | obj->reserve(0); // this is because sometimes "T tmp" allocates objects with |
| 73 | // memory (arena implementation?). use reserve() |
| 74 | // to clear() even if it doesn't always work |
| 75 | } |
| 76 | |
| 77 | // Specialization for deque. Same as STLClearObject but doesn't call reserve |
| 78 | // since deque doesn't have reserve. |
no test coverage detected