mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/fs: use unsafe.Slice instead of deprecated reflect.SliceHeader
This commit is contained in:
parent
7a04f99c72
commit
f8baf29b6e
1 changed files with 2 additions and 7 deletions
|
@ -89,11 +89,7 @@ func mmap(fd int, length int) ([]byte, error) {
|
|||
windows.CloseHandle(h)
|
||||
return nil, os.NewSyscallError("MapViewOfFile", errno)
|
||||
}
|
||||
data := make([]byte, 0)
|
||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&data))
|
||||
hdr.Data = addr
|
||||
hdr.Len = length
|
||||
hdr.Cap = hdr.Len
|
||||
data := unsafe.Slice(addr, length)
|
||||
|
||||
mmapByAddrLock.Lock()
|
||||
mmapByAddr[addr] = h
|
||||
|
@ -105,8 +101,7 @@ func mmap(fd int, length int) ([]byte, error) {
|
|||
func mUnmap(data []byte) error {
|
||||
// flush is not needed, since we perform only reading operation.
|
||||
// In case of write, additional call FlushViewOfFile must be performed.
|
||||
header := (*reflect.SliceHeader)(unsafe.Pointer(&data))
|
||||
addr := header.Data
|
||||
addr := uintptr(unsafe.Pointer(&data[0]))
|
||||
|
||||
mmapByAddrLock.Lock()
|
||||
h, ok := mmapByAddr[addr]
|
||||
|
|
Loading…
Reference in a new issue