MCPcopy Create free account
hub / github.com/apache/impala / STLClearObject

Function STLClearObject

be/src/gutil/stl_util.h:69–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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.
69template<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.

Callers 1

STLClearIfBigFunction · 0.85

Calls 2

reserveMethod · 0.80
swapMethod · 0.45

Tested by

no test coverage detected