transaction: Add support for using raw binary pointers conversation handler
This requires the allocating function to provide a binary pointer that will be free'd by the conversation handlers finalizers. This is for a more advanced usage scenario where the binary conversion may be handled manually.
This commit is contained in:
11
utils.go
11
utils.go
@@ -2,6 +2,8 @@
|
||||
package pam
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
#include <sanitizer/lsan_interface.h>
|
||||
#endif
|
||||
@@ -20,6 +22,7 @@ import (
|
||||
"os"
|
||||
"runtime"
|
||||
"time"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func maybeDoLeakCheck() {
|
||||
@@ -29,3 +32,11 @@ func maybeDoLeakCheck() {
|
||||
C.maybe_do_leak_check()
|
||||
}
|
||||
}
|
||||
|
||||
func allocateCBytes(bytes []byte) BinaryPointer {
|
||||
return BinaryPointer(C.CBytes(bytes))
|
||||
}
|
||||
|
||||
func binaryPointerCBytesFinalizer(ptr BinaryPointer) {
|
||||
C.free(unsafe.Pointer(ptr))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user