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:
Marco Trevisan (Treviño)
2023-11-07 14:22:43 +02:00
parent 0143d11445
commit 89c1e430c1
4 changed files with 196 additions and 0 deletions

View File

@@ -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))
}