func NewAssetDirRef(ref unsafe.Pointer) *AssetDir {
	return (*AssetDir)(ref)
}
NewAssetDirRef converts the C object reference into a raw struct reference without wrapping.
package android
import "C"
import (
	"sync"
	"unsafe"
)
func (x *AssetManager) Ref() *C.AAssetManager {
	if x == nil {
		return nil
	}
	return (*C.AAssetManager)(unsafe.Pointer(x))
}
func (x *AssetManager) Free() {
	if x != nil {
		C.free(unsafe.Pointer(x))
	}
}
func NewAssetManagerRef(ref unsafe.Pointer) *AssetManager {
	return (*AssetManager)(ref)
}
func NewAssetManager() *AssetManager {
	return (*AssetManager)(allocAssetManagerMemory(1))
}
func allocAssetManagerMemory(n int) unsafe.Pointer {
	mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfAssetManagerValue))
	if err != nil {
		panic("memory alloc error: " + err.Error())
	}
	return mem
}
const sizeOfAssetManagerValue = unsafe.Sizeof([1]C.AAssetManager{})
type cgoAllocMap struct {
	mux sync.RWMutex
	m   map[unsafe.Pointer]struct{}
}
var cgoAllocsUnknown = new(cgoAllocMap)
func (a *cgoAllocMap) Add(ptr unsafe.Pointer) {
	a.mux.Lock()
	if a.m == nil {
		a.m = make(map[unsafe.Pointer]struct{})
	}
	a.m[ptr] = struct{}{}
	a.mux.Unlock()
}
func (a *cgoAllocMap) IsEmpty() bool {
	a.mux.RLock()
	isEmpty := len(a.m) == 0
	a.mux.RUnlock()
	return isEmpty
}
func (a *cgoAllocMap) Borrow(b *cgoAllocMap) {
	if b == nil || b.IsEmpty() {
		return
	}
	b.mux.Lock()
	a.mux.Lock()
	for ptr := range b.m {
		if a.m == nil {
			a.m = make(map[unsafe.Pointer]struct{})
		}
		a.m[ptr] = struct{}{}
		delete(b.m, ptr)
	}
	a.mux.Unlock()
	b.mux.Unlock()
}
func (a *cgoAllocMap) Free() {
	a.mux.Lock()
	for ptr := range a.m {
		C.free(ptr)
		delete(a.m, ptr)
	}
	a.mux.Unlock()
}
func (x *AssetManager) PassRef() *C.AAssetManager {
	if x == nil {
		x = (*AssetManager)(allocAssetManagerMemory(1))
	}
	return (*C.AAssetManager)(unsafe.Pointer(x))
}
func (x *AssetDir) Ref() *C.AAssetDir {
	if x == nil {
		return nil
	}
	return (*C.AAssetDir)(unsafe.Pointer(x))
}
func (x *AssetDir) Free() {
	if x != nil {
		C.free(unsafe.Pointer(x))
	}
}