xbytes

package
v0.0.0-...-8299741 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: GPL-3.0 Imports: 2 Imported by: 10

Documentation

Overview

Package xbytes provides additional utilities for working with byte slices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsByte

func ContainsByte(s []byte, c byte) bool

ContainsByte is like bytes.ContainsRune but a bit faster.

func Grow

func Grow(b []byte, n int) []byte

Grow increases length of byte slice by n elements.

If there is not enough capacity the slice is reallocated and copied. The memory for grown elements is not initialized.

func MakeRoom

func MakeRoom(b []byte, n int) []byte

MakeRoom makes sure cap(b) - len(b) >= n.

If there is not enough capacity the slice is reallocated and copied. Length of the slice remains unchanged.

func Realloc

func Realloc(b []byte, n int) []byte

Realloc resizes byte slice to be of length n not preserving content.

If slice length is increased and there is not enough capacity, the slice is reallocated but not copied. The memory for all elements becomes uninitialized.

NOTE semantic is different from C realloc(3) where content is preserved. NOTE use Resize when you need to preserve slice content.

func Realloc64

func Realloc64(b []byte, n int64) []byte

Realloc64 is the same as Realloc but for size typed as int64.

func Resize

func Resize(b []byte, n int) []byte

Resize resizes byte slice to be of length n.

If slice length is increased and there is not enough capacity, the slice is reallocated and copied. The memory for grown elements, if any, is not initialized.

Types

This section is empty.

Jump to

Keyboard shortcuts

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