memory_map.go 645 B

123456789101112131415161718192021222324252627282930
  1. package memory_map
  2. import (
  3. "os"
  4. "strconv"
  5. )
  6. type MemoryBuffer struct {
  7. aligned_length uint64
  8. length uint64
  9. aligned_ptr uintptr
  10. ptr uintptr
  11. Buffer []byte
  12. }
  13. type MemoryMap struct {
  14. File *os.File
  15. file_memory_map_handle uintptr
  16. write_map_views []MemoryBuffer
  17. max_length uint64
  18. End_of_file int64
  19. }
  20. func ReadMemoryMapMaxSizeMb(memoryMapMaxSizeMbString string) (uint32, error) {
  21. if memoryMapMaxSizeMbString == "" {
  22. return 0, nil
  23. }
  24. memoryMapMaxSize64, err := strconv.ParseUint(memoryMapMaxSizeMbString, 10, 32)
  25. return uint32(memoryMapMaxSize64), err
  26. }