func (r *oneIdx) SetData(v []byte) { if r.data != nil { panic("This should not happen") } r.data = data_ptr_t(C.alloc_ptr(unsafe.Pointer(&v[0]), C.ulong(len(v)))) atomic.AddInt64(&ExtraMemoryConsumed, int64(r.datlen)) atomic.AddInt64(&ExtraMemoryAllocCnt, 1) }
func newIdx(v []byte, f uint32) (r *oneIdx) { r = new(oneIdx) r.data = data_ptr_t(C.alloc_ptr(unsafe.Pointer(&v[0]), C.ulong(len(v)))) r.datlen = uint32(len(v)) atomic.AddInt64(&ExtraMemoryConsumed, int64(r.datlen)) atomic.AddInt64(&ExtraMemoryAllocCnt, 1) r.flags = f return }
func gcc_AllocPtr(v []byte) data_ptr_t { ptr := unsafe.Pointer(&v[0]) // see https://github.com/golang/go/issues/15172 return data_ptr_t(C.alloc_ptr(ptr, C.ulong(len(v)))) }