libc

package
v0.0.0-...-a028d74 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

The libc package implements various functions from the C standard library in Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPointer

func AddPointer[T any](ptr *T, offset int) *T

AddPointer does C-style pointer addition: it multiplies offset by sizeof(*ptr) and adds it to ptr.

func Calloc

func Calloc[T any](count, size int64) *T

Calloc allocates a block of memory for count objects of size bytes each.

func Getchar

func Getchar() int32

func GoString

func GoString(s *byte) string

GoString returns s converted from a C string to a Go string.

func Malloc

func Malloc[T any](n int64) *T

Malloc allocates n bytes of memory. It informs the garbage collector that the memory will be used to store objects of type T.

func Memchr

func Memchr(s *byte, c int32, n int64) *byte

Memchr returns a pointer to the first occurrence of c in string s. It returns nil if no such byte exists within n bytes.

func Memcmp

func Memcmp(s1 *byte, s2 *byte, n int64) int32

func MemcpyChk

func MemcpyChk(dest *byte, src *byte, length int64, destlen int64) *byte

MemcpyChk copies length bytes from src to dest. If length is greater than destlen (interpreted as unsigned integers), it will panic.

func Memmove

func Memmove(dst *byte, src *byte, length int64) *byte

Memmove copies length bytes from src to dst. The blocks of memory may overlap.

func Memset

func Memset(b *byte, c byte, length int64) *byte

Memset fills the memory at b with bytes of the value c.

func MemsetChk

func MemsetChk(b *byte, c byte, length int64, destlen int64) *byte

MemsetChk fills the memory at b with bytes of the value c. If length is greater than destlen (interpreted as unsigned integers), it will panic.

func MemsetPattern16

func MemsetPattern16(b *byte, pattern16 *byte, length int64)

MemsetPattern16 fills the memory at b with a 16-byte pattern.

func Printf

func Printf(format *byte, args ...any) int32

func Putc

func Putc(c int32, stream *os.File) int32

func Putchar

func Putchar(c int32) int32

func Puts

func Puts(s *byte) int32

func Scanf

func Scanf(format *byte, args ...any) int32

func StrcatChk

func StrcatChk(dest *byte, src *byte, destlen int64) *byte

StrcatChk concatenates two C strings. It panics if the space required is more than destlen bytes.

func Strchr

func Strchr(s *byte, c int32) *byte

func Strcmp

func Strcmp(s1 *byte, s2 *byte) int32

func Strcpy

func Strcpy(s1 *byte, s2 *byte) *byte

func Strcspn

func Strcspn(s1 *byte, s2 *byte) int64

func Strlen

func Strlen(s *byte) int64

func Strncat

func Strncat(s1 *byte, s2 *byte, n int64) *byte

func Strncmp

func Strncmp(s1 *byte, s2 *byte, n int64) int32

func Strncpy

func Strncpy(s1 *byte, s2 *byte, n int64) *byte

func Strpbrk

func Strpbrk(s1 *byte, s2 *byte) *byte

func Strrchr

func Strrchr(s *byte, c int32) *byte

func Strspn

func Strspn(s1 *byte, s2 *byte) int64

func Strstr

func Strstr(s1 *byte, s2 *byte) *byte

func VAArg

func VAArg(list *byte) *byte

VAArg returns a pointer to the next argument in a varargs list. The actual type of list is *[]interface{}, but it is declared as void * in C.

Types

This section is empty.

Jump to

Keyboard shortcuts

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