aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-13 19:31:27 +0000
committerlloyd <[email protected]>2010-03-13 19:31:27 +0000
commit634f3d27f7faad1dc558821382f71ecc2194637d (patch)
treedd4e626a4ac3ff5c928460b9e133007023d3321c /src/utils
parent1fe724175fdad94d724d401c46b5187f5f539136 (diff)
parent72a154f3d7eef286b42a116232f8b7be88ccb6d6 (diff)
propagate from branch 'net.randombit.botan' (head aabb4c3bc2207ceac1920573293b95d138a185df)
to branch 'net.randombit.botan.c++0x' (head 179172dd6952f15f832855f4ec0ac48cb1e08188)
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/mlock.cpp9
-rw-r--r--src/utils/mlock.h5
2 files changed, 14 insertions, 0 deletions
diff --git a/src/utils/mlock.cpp b/src/utils/mlock.cpp
index 5d6fc3591..bc6ddc67e 100644
--- a/src/utils/mlock.cpp
+++ b/src/utils/mlock.cpp
@@ -16,6 +16,15 @@
namespace Botan {
+bool has_mlock()
+ {
+ byte buf[4096];
+ if(!lock_mem(&buf, sizeof(buf)))
+ return false;
+ unlock_mem(&buf, sizeof(buf));
+ return true;
+ }
+
/*
* Lock an area of memory into RAM
*/
diff --git a/src/utils/mlock.h b/src/utils/mlock.h
index 66ced9e63..fea56d438 100644
--- a/src/utils/mlock.h
+++ b/src/utils/mlock.h
@@ -13,6 +13,11 @@
namespace Botan {
/**
+* Check if we can at least potentially lock memory
+*/
+bool has_mlock();
+
+/**
* Lock memory into RAM if possible
* @param addr the start of the memory block
* @param length the length of the memory block in bytes