// zero out memory and then free func (self *Buffer) Free() { C.sodium_memzero(self.ptr, self.size) C.free(self.ptr) }
func MemZero(b1 []byte) { if len(b1) > 0 { C.sodium_memzero(unsafe.Pointer(&b1[0]), C.size_t(len(b1))) } }
// does not check for negatives func malloc(size C.size_t) *Buffer { ptr := C.malloc(size) C.sodium_memzero(ptr, size) buffer := &Buffer{ptr: ptr, size: size, length: C.int(size)} return buffer }