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

Function mmapFile

index/mmap_bsd.go:21–39  ·  view source on GitHub ↗
(f *os.File)

Source from the content-addressed store, hash-verified

19)
20
21func mmapFile(f *os.File) mmapData {
22 st, err := f.Stat()
23 if err != nil {
24 log.Fatal(err)
25 }
26 size := st.Size()
27 if int64(int(size+4095)) != size+4095 {
28 log.Fatalf("%s: too large for mmap", f.Name())
29 }
30 n := int(size)
31 if n == 0 {
32 return mmapData{f, nil}
33 }
34 data, err := syscall.Mmap(int(f.Fd()), 0, (n+4095)&^4095, _PROT_READ, _MAP_SHARED)
35 if err != nil {
36 log.Fatalf("mmap %s: %v", f.Name(), err)
37 }
38 return mmapData{f, data[:n]}
39}

Callers 2

mmapFunction · 0.70
addFileMethod · 0.70

Calls 1

NameMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…