aboutsummaryrefslogtreecommitdiff
path: root/internal/crypt/mem.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/crypt/mem.go')
-rw-r--r--internal/crypt/mem.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/crypt/mem.go b/internal/crypt/mem.go
new file mode 100644
index 0000000..9c1d21c
--- /dev/null
+++ b/internal/crypt/mem.go
@@ -0,0 +1,16 @@
+package crypt
+
+import (
+ "fmt"
+ "os"
+ "syscall"
+)
+
+func TryMlock(b []byte) {
+ if len(b) == 0 {
+ return
+ }
+ if err := syscall.Mlock(b); err != nil {
+ fmt.Fprintf(os.Stderr, "mlock warning: %v\n", err)
+ }
+}