MCPcopy
hub / github.com/etcd-io/bbolt / UnsafeByteSlice

Function UnsafeByteSlice

internal/common/unsafe.go:15–27  ·  view source on GitHub ↗
(base unsafe.Pointer, offset uintptr, i, j int)

Source from the content-addressed store, hash-verified

13}
14
15func UnsafeByteSlice(base unsafe.Pointer, offset uintptr, i, j int) []byte {
16 // See: https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices
17 //
18 // This memory is not allocated from C, but it is unmanaged by Go's
19 // garbage collector and should behave similarly, and the compiler
20 // should produce similar code. Note that this conversion allows a
21 // subslice to begin after the base address, with an optional offset,
22 // while the URL above does not cover this case and only slices from
23 // index 0. However, the wiki never says that the address must be to
24 // the beginning of a C allocation (or even that malloc was used at
25 // all), so this is believed to be correct.
26 return (*[MaxAllocSize]byte)(UnsafeAdd(base, offset))[i:j:j]
27}

Callers 7

TestNode_read_LeafPageFunction · 0.92
writeMethod · 0.92
WriteInodeToPageFunction · 0.85
hexdumpMethod · 0.85
KeyMethod · 0.85
KeyMethod · 0.85
ValueMethod · 0.85

Calls 1

UnsafeAddFunction · 0.85

Tested by 1

TestNode_read_LeafPageFunction · 0.74