aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-11-29 18:58:54 +0000
committerlloyd <[email protected]>2012-11-29 18:58:54 +0000
commit12c128c1fbb483ae9042b47fc544adf0e55d0693 (patch)
tree46aa39dcfb055c84778fa842a2d66249f6d175c8 /src/alloc
parent2d8dff7079d4a8eabd848bd0e88b38a2112b333e (diff)
Add new helper zap which zeros a vector, clears it, and then calls
shrink_to_fit to actually deallocate memory.
Diffstat (limited to 'src/alloc')
-rw-r--r--src/alloc/secmem.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/alloc/secmem.h b/src/alloc/secmem.h
index 537f0ef44..2f4d65f33 100644
--- a/src/alloc/secmem.h
+++ b/src/alloc/secmem.h
@@ -168,6 +168,18 @@ void zeroise(std::vector<T, Alloc>& vec)
clear_mem(&vec[0], vec.size());
}
+/**
+* Zeroise the values then free the memory
+* @param vec the vector to zeroise and free
+*/
+template<typename T, typename Alloc>
+void zap(std::vector<T, Alloc>& vec)
+ {
+ zeroise(vec);
+ vec.clear();
+ vec.shrink_to_fit();
+ }
+
}
#endif