func flush(addr, len uintptr) error { errno := syscall.FlushViewOfFile(addr, len) if errno != nil { return os.NewSyscallError("FlushViewOfFile", errno) } handleLock.Lock() defer handleLock.Unlock() handle, ok := handleMap[addr] if !ok { // should be impossible; we would've errored above return errors.New("unknown base address") } errno = syscall.FlushFileBuffers(handle) return os.NewSyscallError("FlushFileBuffers", errno) }
func unmap(p []byte) error { addr := uintptr(unsafe.Pointer(&p[0])) syscall.FlushViewOfFile(addr, uintptr(len(p))) err := syscall.UnmapViewOfFile(addr) if err != nil { return err } handleLock.Lock() defer handleLock.Unlock() handle, ok := handleMap[addr] if !ok { // should be impossible; we would've errored above return errors.New("unknown base address") } delete(handleMap, addr) e := syscall.CloseHandle(syscall.Handle(handle)) return os.NewSyscallError("CloseHandle", e) }
func flush(addr, len uintptr) error { errno := syscall.FlushViewOfFile(addr, len) return os.NewSyscallError("FlushViewOfFile", errno) }