func WrapPointer(a Allocator, ptr unsafe.Pointer, size uintptr) Buffer {
	res := &buffer{alloc: a, size: size, ptr: ptr}
	runtime.SetFinalizer(res, func(obj *buffer) {
		allocator := obj.alloc
		go allocator.Context().Run(func() error {
			allocator.Free(obj.ptr, obj.size)
			return nil
		})
	})
	return res
}
WrapPointer wraps a pointer in a Buffer.
You must specify the Allocator from which the pointer
originated and the size of the buffer.

After calling this, you should not use the pointer
outside of the buffer.
The Buffer will automatically free the pointer.
package cuda
import "C"
import (
	"fmt"
	"runtime"
	"unsafe"
)
type Buffer interface {
	Allocator() Allocator
	Size() uintptr
	WithPtr(f func(ptr unsafe.Pointer))
}
type buffer struct {
	alloc Allocator
	size  uintptr
	ptr   unsafe.Pointer
}
func AllocBuffer(a Allocator, size uintptr) (Buffer, error) {
	ptr, err := a.Alloc(size)
	if err != nil {
		return nil, err
	}
	return WrapPointer(a, ptr, size), nil
}