MCPcopy Index your code
hub / github.com/google/codesearch / mmapFile

Function mmapFile

index/mmap_linux.go:13–31  ·  view source on GitHub ↗
(f *os.File)

Source from the content-addressed store, hash-verified

11)
12
13func mmapFile(f *os.File) mmapData {
14 st, err := f.Stat()
15 if err != nil {
16 log.Fatal(err)
17 }
18 size := st.Size()
19 if int64(int(size+4095)) != size+4095 {
20 log.Fatalf("%s: too large for mmap", f.Name())
21 }
22 n := int(size)
23 if n == 0 {
24 return mmapData{f, nil}
25 }
26 data, err := syscall.Mmap(int(f.Fd()), 0, (n+4095)&^4095, syscall.PROT_READ, syscall.MAP_SHARED)
27 if err != nil {
28 log.Fatalf("mmap %s: %v", f.Name(), err)
29 }
30 return mmapData{f, data[:n]}
31}

Callers

nothing calls this directly

Calls 1

NameMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…