// Windows mmap always mapes the entire file regardless of the specified length.
196581
func mmap(length int, hfile uintptr) ([]byte, error) {
	h, errno := syscall.CreateFileMapping(syscall.Handle(hfile), nil, syscall.PAGE_READWRITE, 0, 0, nil)
	if h == 0 {
		return nil, os.NewSyscallError("CreateFileMapping", errno)
	}

	addr, errno := syscall.MapViewOfFile(h, syscall.FILE_MAP_WRITE, 0, 0, 0)
	if addr == 0 {
		return nil, os.NewSyscallError("MapViewOfFile", errno)
	}
	handleLock.Lock()
	handleMap[addr] = h
	handleLock.Unlock()

	m := MMap{}
	dh := m.header()
	dh.Data = addr
	dh.Len = length
	dh.Cap = length

	return m, nil
}
1061892
func (s *SearchSource) DefaultRescoreWindowSize(defaultRescoreWindowSize int) *SearchSource {
	s.defaultRescoreWindowSize = &defaultRescoreWindowSize
	return s
}
1039152
func Int64Map(src map[string]int64) map[string]*int64 {
	dst := make(map[string]*int64)
	for k, val := range src {
		v := val
		dst[k] = &v
	}
	return dst
}
804784
func Uint64Map(src map[string]uint64) map[string]*uint64 {
	dst := make(map[string]*uint64)
	for k, val := range src {
		v := val
		dst[k] = &v
	}
	return dst
}
509238
func (mmap MarshalMap) StringMap(key string) (map[string]string, error) {
	val, exists := mmap.Value(key)
	if !exists {
		return nil, fmt.Errorf(`"%s" is not set`, key)
	}

	switch val.(type) {
	case map[string]string:
		return val.(map[string]string), nil

	default:
		valueMeta := reflect.ValueOf(val)
		if valueMeta.Kind() != reflect.Map {
			return nil, fmt.Errorf(`"%s" is expected to be a map[string]string but is %T`, key, val)
		}

		result := make(map[string]string)
		for _, keyMeta := range valueMeta.MapKeys() {
			strKey, isString := keyMeta.Interface().(string)
			if !isString {
				return nil, fmt.Errorf(`"%s" is expected to be a map[string]string. Key is not a string`, key)
			}

			value := valueMeta.MapIndex(keyMeta)
			strValue, isString := value.Interface().(string)
			if !isString {
				return nil, fmt.Errorf(`"%s" is expected to be a map[string]string. Value is not a string`, key)
			}

			result[strKey] = strValue
		}

		return result, nil
	}
}
1012619
func Int64Map(result interface{}, err error) (map[string]int64, error) {
	values, err := Values(result, err)
	if err != nil {
		return nil, err
	}
	if len(values)%2 != 0 {
		return nil, errors.New("redigo: Int64Map expects even number of values result")
	}
	m := make(map[string]int64, len(values)/2)
	for i := 0; i < len(values); i += 2 {
		key, ok := values[i].([]byte)
		if !ok {
			return nil, errors.New("redigo: Int64Map key not a bulk string value")
		}
		value, err := Int64(values[i+1], nil)
		if err != nil {
			return nil, err
		}
		m[string(key)] = value
	}
	return m, nil
}
250846
func Munmap(b []byte) (err error) {
	err = syscall.Munmap(b)
	if err == nil {
		atomic.AddUint64(&mapCount, ^uint64(0)) // decrement
	}
	return err
}
1295853
func (m *mapReact) Length() int {
	var l int
	m.ro.RLock()
	l = len(m.ma)
	m.ro.RUnlock()
	return l
}
518610
func parseGWMetaMap(gwMetaBuf []byte) map[string]string {
	// Get gwMetaV1.Meta map.
	metaMapResult := gjson.GetBytes(gwMetaBuf, "meta").Map()
	metaMap := make(map[string]string)
	for key, valResult := range metaMapResult {
		metaMap[key] = valResult.String()
	}
	return metaMap
}
73457
func (c *Connect) AllocPages(pageSizes map[int]int64, startCell int, cellCount uint, flags NodeAllocPagesFlags) (int, error) {
	if C.LIBVIR_VERSION_NUMBER < 1002009 {
		return 0, makeNotImplementedError("virNodeAllocPages")
	}
	cpages := make([]C.uint, len(pageSizes))
	ccounts := make([]C.ulonglong, len(pageSizes))

	i := 0
	for key, val := range pageSizes {
		cpages[i] = C.uint(key)
		ccounts[i] = C.ulonglong(val)
		i++
	}

	var err C.virError
	ret := C.virNodeAllocPagesWrapper(c.ptr, C.uint(len(pageSizes)), (*C.uint)(unsafe.Pointer(&cpages)),
		(*C.ulonglong)(unsafe.Pointer(&ccounts)), C.int(startCell), C.uint(cellCount), C.uint(flags), &err)
	if ret == -1 {
		return 0, makeError(&err)
	}

	return int(ret), nil
}
1108123
func (b MemFile) Truncate(size int64) (err error) {
	b.mutex.Lock()
	err = b.Buffer.Truncate(size)
	b.mutex.Unlock()
	return
}
502169
func (mmap MarshalMap) StringSliceMap(key string) (map[string][]string, error) {
	return mmap.StringArrayMap(key)
}
1053581
func (p *Profile) ParseMemoryMap(rd io.Reader) error {
	b := bufio.NewReader(rd)

	var attrs []string
	var r *strings.Replacer
	const delimiter = "="
	for {
		l, err := b.ReadString('\n')
		if err != nil {
			if err != io.EOF {
				return err
			}
			if l == "" {
				break
			}
		}
		if l = strings.TrimSpace(l); l == "" {
			continue
		}

		if r != nil {
			l = r.Replace(l)
		}
		m, err := parseMappingEntry(l)
		if err != nil {
			if err == errUnrecognized {
				// Recognize assignments of the form: attr=value, and replace
				// $attr with value on subsequent mappings.
				if attr := strings.SplitN(l, delimiter, 2); len(attr) == 2 {
					attrs = append(attrs, "$"+strings.TrimSpace(attr[0]), strings.TrimSpace(attr[1]))
					r = strings.NewReplacer(attrs...)
				}
				// Ignore any unrecognized entries
				continue
			}
			return err
		}
		if m == nil || (m.File == "" && len(p.Mapping) != 0) {
			// In some cases the first entry may include the address range
			// but not the name of the file. It should be followed by
			// another entry with the name.
			continue
		}
		if len(p.Mapping) == 1 && p.Mapping[0].File == "" {
			// Update the name if this is the entry following that empty one.
			p.Mapping[0].File = m.File
			continue
		}
		p.Mapping = append(p.Mapping, m)
	}
	p.remapLocationIDs()
	p.remapFunctionIDs()
	p.remapMappingIDs()
	return nil
}
555516
func (env *Env) SetMapSize(size int64) error {
	if size < 0 {
		return errNegSize
	}
	ret := C.mdb_env_set_mapsize(env._env, C.size_t(size))
	return operrno("mdb_env_set_mapsize", ret)
}
1222184
func InitMapInfo(tcpMaxEntries, anyMaxEntries int) {
	mapInfo = make(map[MapType]mapAttributes)
	natMaps := nat.GlobalMaps(true, true)
	natV4 := natMaps[0]
	natV6 := natMaps[1]

	mapType := MapTypeIPv4TCPLocal
	for _, maxEntries := range []int{MapNumEntriesLocal, tcpMaxEntries} {
		setupMapInfo(MapType(mapType), "CT_MAP_TCP4",
			int(unsafe.Sizeof(tuple.TupleKey4{})), maxEntries,
			ct4DumpParser, natV4)
		mapType++
		setupMapInfo(MapType(mapType), "CT_MAP_TCP6",
			int(unsafe.Sizeof(tuple.TupleKey6{})), maxEntries,
			ct6DumpParser, natV6)
		mapType++
	}
	for _, maxEntries := range []int{MapNumEntriesLocal, anyMaxEntries} {
		setupMapInfo(MapType(mapType), "CT_MAP_ANY4",
			int(unsafe.Sizeof(tuple.TupleKey4{})), maxEntries,
			ct4DumpParser, natV4)
		mapType++
		setupMapInfo(MapType(mapType), "CT_MAP_ANY6",
			int(unsafe.Sizeof(tuple.TupleKey6{})), maxEntries,
			ct6DumpParser, natV6)
		mapType++
	}
}
644013
func (mmap MarshalMap) Delete(key string) {
	mmap.resolvePath(key, mmap, func(p, k reflect.Value, v interface{}) {
		if v != nil {
			p.SetMapIndex(k, reflect.Value{})
		}
	})
}
420150
func (s *wfScope) replaceMap() map[string]string {
	replaceMap := make(map[string]string)
	for key, val := range s.scope {
		valStr, ok := val.(string)
		if ok {
			replaceMap[key] = valStr
		}
	}
	return replaceMap
}