ptrutil

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocateSliceSpaceAndBind

func AllocateSliceSpaceAndBind(p unsafe.Pointer, length uint64, typ reflect.Type) unsafe.Pointer

Allocates a new slice of the given length, of the given type. Note: p is assumed to be a pointer to a slice header, and the pointer is assumed to keep the referenced data alive as long as necessary, away from the GC. The allocated space is zeroed out.

func AllocateSpace

func AllocateSpace(p unsafe.Pointer, typ reflect.Type) unsafe.Pointer

Allocates space of the given length and returns a pointer to the contents The allocated space is zeroed out.

func BytesAllocFn

func BytesAllocFn(p unsafe.Pointer, length uint64) unsafe.Pointer

func IfacePtrToPtr

func IfacePtrToPtr(val *interface{}) unsafe.Pointer

Types

type AllocationFn

type AllocationFn func(p unsafe.Pointer) unsafe.Pointer

type SliceAllocationFn

type SliceAllocationFn func(p unsafe.Pointer, length uint64) unsafe.Pointer

func MakeSliceAllocFn

func MakeSliceAllocFn(typ reflect.Type) SliceAllocationFn

func (SliceAllocationFn) MutateLenOrAllocNew added in v0.1.5

func (f SliceAllocationFn) MutateLenOrAllocNew(p unsafe.Pointer, length uint64) unsafe.Pointer

Checks the capacity of the slice first. If sufficient, it mutates the length and returns the pointer to the contents. If not sufficient, it allocates a new slice using the underlying allocation function, and returns the pointer to the new contents.

type SliceHeader

type SliceHeader struct {
	Data unsafe.Pointer
	Len  int
	Cap  int
}

func GetSliceHeader

func GetSliceHeader(p unsafe.Pointer, length uint64) *SliceHeader

func ReadSliceHeader

func ReadSliceHeader(p unsafe.Pointer) *SliceHeader

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL