// readGNUSparseMap0x1 reads the sparse map as stored in GNU's PAX sparse format
// version 0.1. The sparse map is stored in the PAX headers.
777818
func readGNUSparseMap0x1(extHdrs map[string]string) ([]sparseEntry, error) {
	// Get number of entries.
	// Use integer overflow resistant math to check this.
	numEntriesStr := extHdrs[paxGNUSparseNumBlocks]
	numEntries, err := strconv.ParseInt(numEntriesStr, 10, 0) // Intentionally parse as native int
	if err != nil || numEntries < 0 || int(2*numEntries) < int(numEntries) {
		return nil, ErrHeader
	}

	// There should be two numbers in sparseMap for each entry.
	sparseMap := strings.Split(extHdrs[paxGNUSparseMap], ",")
	if int64(len(sparseMap)) != 2*numEntries {
		return nil, ErrHeader
	}

	// Loop through the entries in the sparse map.
	// numEntries is trusted now.
	sp := make([]sparseEntry, 0, numEntries)
	for i := int64(0); i < numEntries; i++ {
		offset, err := strconv.ParseInt(sparseMap[2*i], 10, 64)
		if err != nil {
			return nil, ErrHeader
		}
		numBytes, err := strconv.ParseInt(sparseMap[2*i+1], 10, 64)
		if err != nil {
			return nil, ErrHeader
		}
		sp = append(sp, sparseEntry{offset: offset, numBytes: numBytes})
	}
	return sp, nil
}
644840
func (o *Generator) ReadV1(ids []UUID) {
	for i := range ids {
		ids[i] = o.NewV1()
	}
}
626384
func (p *Parser) parseRegex() (*RegexLiteral, error) {
	nextRune := p.peekRune()
	if isWhitespace(nextRune) {
		p.consumeWhitespace()
	}

	// If the next character is not a '/', then return nils.
	nextRune = p.peekRune()
	if nextRune != '/' {
		return nil, nil
	}

	tok, pos, lit := p.s.ScanRegex()

	if tok == BADESCAPE {
		msg := fmt.Sprintf("bad escape: %s", lit)
		return nil, &ParseError{Message: msg, Pos: pos}
	} else if tok == BADREGEX {
		msg := fmt.Sprintf("bad regex: %s", lit)
		return nil, &ParseError{Message: msg, Pos: pos}
	} else if tok != REGEX {
		return nil, newParseError(tokstr(tok, lit), []string{"regex"}, pos)
	}

	re, err := regexp.Compile(lit)
	if err != nil {
		return nil, &ParseError{Message: err.Error(), Pos: pos}
	}

	return &RegexLiteral{Val: re}, nil
}
235825
func ParseCPUs(value string) (int64, error) {
	cpu, ok := new(big.Rat).SetString(value)
	if !ok {
		return 0, fmt.Errorf("failed to parse %v as a rational number", value)
	}
	nano := cpu.Mul(cpu, big.NewRat(1e9, 1))
	if !nano.IsInt() {
		return 0, fmt.Errorf("value is too precise")
	}
	return nano.Num().Int64(), nil
}
1096892
func (reader PluginConfigReaderWithError) GetMap(key string, defaultValue tcontainer.MarshalMap) (tcontainer.MarshalMap, error) {
	key = reader.config.registerKey(key)
	if reader.HasValue(key) {
		return reader.config.Settings.MarshalMap(key)
	}
	return defaultValue, nil
}
119910
func (p *Profile) ParseMemoryMap(rd io.Reader) error {
	return p.ParseMemoryMapFromScanner(bufio.NewScanner(rd))
}
1366461
func ParseMap(raw []string) Map {
	m := make(Map, len(raw))
	for _, t := range raw {
		m.Add(Parse(t))
	}
	return m
}
250846
func Munmap(b []byte) (err error) {
	err = syscall.Munmap(b)
	if err == nil {
		atomic.AddUint64(&mapCount, ^uint64(0)) // decrement
	}
	return err
}
1304870
func (c *ClassifierDeserializer) ReadMetadataAtPrefix(prefix string) (ClassifierMetadataV1, error) {
	var ret ClassifierMetadataV1
	err := c.GetJSONForKey(c.Prefix(prefix, "METADATA"), &ret)
	return ret, err
}
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
}
980296
func (g *Oper) Read(dummy string) error {
	key := operGlobalPath
	return g.StateDriver.ReadState(key, g, json.Unmarshal)
}
865005
func (rb *Bitmap) ReadFromMsgpack(stream io.Reader) (int64, error) {
	return 0, rb.highlowcontainer.readFromMsgpack(stream)
}
409024
func ParseMapFromGKE(clusterLister ClusterLister, projID, zone string) (*Map, error) {
	clustersResp, err := clusterLister.List(projID, zone)
	if err != nil {
		return nil, err
	}
	return &Map{nameMap: clusterNamesToMap(clustersResp.Clusters)}, nil
}
1058295
func parseMap(m Map) (map[int]interface{}, map[string]string) {
	var options = make(map[int]interface{})
	var headers = make(map[string]string)

	if m == nil {
		return options, headers
	}

	for k, v := range m {
		// integer is option
		if kInt, ok := k.(int); ok {
			// don't need to validate
			options[kInt] = v
		} else if kString, ok := k.(string); ok {
			kStringUpper := strings.ToUpper(kString)
			if kInt, ok := CONST[kStringUpper]; ok {
				options[kInt] = v
			} else {
				// it should be header, but we still need to validate it's type
				if vString, ok := v.(string); ok {
					headers[kString] = vString
				}
			}
		}
	}

	return options, headers
}
46457
func (renderer *Renderer) ReadPixels(rect *Rect, format uint32, pixels unsafe.Pointer, pitch int) error {
	return errorFromInt(int(
		C.SDL_RenderReadPixels(
			renderer.cptr(),
			rect.cptr(),
			C.Uint32(format),
			pixels,
			C.int(pitch))))
}
601919
func ParseGeometry(gi interface{}) (geom Geometry, err error) {
	switch g := gi.(type) {
	case map[string]interface{}:
		coord := g["coordinates"]
		switch typ := g["type"]; typ {
		case "Point":
			return parsePoint(coord)
		case "LineString":
			return parseLineString(coord)
		case "MultiPoint":
			return parseMultiPoint(coord)
		case "MultiLineString":
			return parseMultiLineString(coord)
		case "Polygon":
			return parsePolygon(coord)
		case "MultiPolygon":
			return parseMultiPolygon(coord)
		case "GeometryCollection":
			return parseGeometryCollection(g["geometries"])
		default:
			err = errors.New(fmt.Sprintf("ParseError: Unknown geometry type %s", typ))
			break
		}
	}
	return geom, err
}
224546
func (g *Oper) ReadAll() ([]core.State, error) {
	return g.StateDriver.ReadAllState(operGlobalPrefix, g, json.Unmarshal)
}