-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
4 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/qjfoidnh/BaiduPCS-Go | ||
|
||
go 1.18 | ||
go 1.23 | ||
|
||
require ( | ||
github.com/GeertJohan/go.incremental v1.0.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,7 @@ | ||
package cachepool | ||
|
||
import ( | ||
"reflect" | ||
"unsafe" | ||
) | ||
|
||
//go:linkname mallocgc runtime.mallocgc | ||
func mallocgc(size uintptr, typ uintptr, needzero bool) unsafe.Pointer | ||
|
||
//go:linkname rawbyteslice runtime.rawbyteslice | ||
func rawbyteslice(size int) (b []byte) | ||
|
||
// RawByteSlice point to runtime.rawbyteslice | ||
func RawByteSlice(size int) (b []byte) { | ||
return rawbyteslice(size) | ||
} | ||
|
||
// RawMalloc allocates a new slice. The slice is not zeroed. | ||
func RawMalloc(size int) unsafe.Pointer { | ||
return mallocgc(uintptr(size), 0, false) | ||
} | ||
|
||
// RawMallocByteSlice allocates a new byte slice. The slice is not zeroed. | ||
// RawMallocByteSlice allocates a new byte slice. | ||
func RawMallocByteSlice(size int) []byte { | ||
p := mallocgc(uintptr(size), 0, false) | ||
b := *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ | ||
Data: uintptr(p), | ||
Len: size, | ||
Cap: size, | ||
})) | ||
return b | ||
bytesArray := make([]byte, size) | ||
return bytesArray | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters