cextend

package
v0.0.0-...-986f64f Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

本包提供C语言功能的go语言API。

本包使用了cgo,编译需要cgo,在使用时请考虑这对交叉编译的影响!

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Calloc

func Calloc(nitems uint, size uint) (ptr unsafe.Pointer)

C语言<stdlib.h>中提供的calloc函数的go语言API

func Free

func Free(ptr unsafe.Pointer)

C语言<stdlib.h>中提供的free函数的go语言API

func Malloc

func Malloc(size uint) (ptr unsafe.Pointer)

C语言<stdlib.h>中提供的malloc函数的go语言API

Example
//获得内存
ptr := Malloc(4)
//获取成败判断
if ptr != nil {
	//失败处理
	//......
}
//不用时释放获取的内存,避免内存泄露
defer Free(ptr)
//使用内存
//.......
Output:

func Memcpy

func Memcpy(dest, src unsafe.Pointer, n uint)

C语言<string.h>中提供的memcpy函数的go语言API

func Realloc

func Realloc(ptr unsafe.Pointer, size uint) (nptr unsafe.Pointer)

C语言<stdlib.h>中提供的realloc函数的go语言API

Types

This section is empty.

Jump to

Keyboard shortcuts

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