diff options
| author | 2025-03-09 17:47:56 +0100 | |
|---|---|---|
| committer | 2025-12-01 22:08:04 +0100 | |
| commit | b1af8fd87760b34e3ff2fd3bda38f211815a0473 (patch) | |
| tree | 9317fad1a7ec298d7a8d2678e4e422953bbc6f33 /vendor/github.com/ncruces/go-sqlite3/internal/util/mmap_windows.go | |
| parent | [chore] update URLs to forked source (diff) | |
| download | gotosocial-b1af8fd87760b34e3ff2fd3bda38f211815a0473.tar.xz | |
[chore] remove vendor
Diffstat (limited to 'vendor/github.com/ncruces/go-sqlite3/internal/util/mmap_windows.go')
| -rw-r--r-- | vendor/github.com/ncruces/go-sqlite3/internal/util/mmap_windows.go | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/vendor/github.com/ncruces/go-sqlite3/internal/util/mmap_windows.go b/vendor/github.com/ncruces/go-sqlite3/internal/util/mmap_windows.go deleted file mode 100644 index f1fee0b50..000000000 --- a/vendor/github.com/ncruces/go-sqlite3/internal/util/mmap_windows.go +++ /dev/null @@ -1,56 +0,0 @@ -package util - -import ( - "os" - "reflect" - "unsafe" - - "golang.org/x/sys/windows" -) - -type MappedRegion struct { - windows.Handle - Data []byte - addr uintptr -} - -func MapRegion(f *os.File, offset int64, size int32) (*MappedRegion, error) { - maxSize := offset + int64(size) - h, err := windows.CreateFileMapping( - windows.Handle(f.Fd()), nil, windows.PAGE_READWRITE, - uint32(maxSize>>32), uint32(maxSize), nil) - if h == 0 { - return nil, err - } - - const allocationGranularity = 64 * 1024 - align := offset % allocationGranularity - offset -= align - - a, err := windows.MapViewOfFile(h, windows.FILE_MAP_WRITE, - uint32(offset>>32), uint32(offset), uintptr(size)+uintptr(align)) - if a == 0 { - windows.CloseHandle(h) - return nil, err - } - - ret := &MappedRegion{Handle: h, addr: a} - // SliceHeader, although deprecated, avoids a go vet warning. - sh := (*reflect.SliceHeader)(unsafe.Pointer(&ret.Data)) - sh.Data = a + uintptr(align) - sh.Len = int(size) - sh.Cap = int(size) - return ret, nil -} - -func (r *MappedRegion) Unmap() error { - if r.Data == nil { - return nil - } - err := windows.UnmapViewOfFile(r.addr) - if err != nil { - return err - } - r.Data = nil - return windows.CloseHandle(r.Handle) -} |
