void String::free() { if (elements) { std::for_each(elements, end, [this](char &c){ alloc.destroy(&c); }); alloc.deallocate(elements, end - elements); } }
void StrVec::free() { if (elements) { for (auto p = first_free; p != elements;) { alloc.destroy(--p); } alloc.deallocate(elements, cap - elements); } }
inline void BigNumber::release() {//Free BigNumber space if(first_free){ while(first_free != val) alloc.destroy(--first_free); alloc.deallocate(val,cap); } val=first_free=NULL; cap=len=dot=0; }
inline BigNumber::~BigNumber() {//Destructor if(val){ for(;first_free!=val;) alloc.destroy(--first_free); alloc.deallocate(val,cap); } val=first_free=NULL; cap=0; dot=len=0; }
void String::free() { for(char *p = s;p < s+sz;++p) alloc.destroy(p); alloc.deallocate(s,sz); }
static void destroy(T* ptr) { alloc_.destroy(ptr); alloc_.deallocate(ptr, 1); }