Skip to content

Commit

Permalink
Alloc, Free
Browse files Browse the repository at this point in the history
  • Loading branch information
lemon-mint committed Jun 8, 2021
1 parent 40a8cfa commit f1a6c86
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sys.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ func SysFree(v unsafe.Pointer, n uintptr, sysStat *SysMemStat)

//go:linkname SysAlloc runtime.sysAlloc
//go:linkname SysFree runtime.sysFree

var libUsefulMemStat SysMemStat

// Alloc allocates unmanaged memory (Calls SysAlloc)
func Alloc(size uintptr) unsafe.Pointer {
return SysAlloc(size, &libUsefulMemStat)
}

// Free frees memory allocated by Alloc
func Free(ptr unsafe.Pointer, size uintptr) {
SysFree(ptr, size, &libUsefulMemStat)
}

0 comments on commit f1a6c86

Please sign in to comment.