// Code generated by libc-gen. DO NOT EDIT.

package rtree

import (
	"bytes"
	"strconv"
	"unsafe"
)

func (m *Module) _strlen(s int32) int32 {
	return int32(bytes.IndexByte((*m.memory)[uint32(s):], 0))
}
func (m *Module) _strtod(s, endptr int32) float64 {
	return m._strtod_helper(s, endptr, 64)
}

func (m *Module) _strtod_helper(s, endptr int32, bitSize int) float64 {
	m0 := (*m.memory)[uint32(s):]
	m1 := bytes.TrimLeft(m0, " \t\n\v\f\r")
	m2 := bytes.TrimLeft(m1, "+-.0123456789abcdefinptxyABCDEFINPTXY")
	prefix := len(m0) - len(m1)
	digits := len(m1) - len(m2)

	var val float64
	for ; digits > 0; digits-- {
		var err error
		str := unsafe.String(&m1[0], digits)
		val, err = strconv.ParseFloat(str, bitSize)
		if e, ok := err.(*strconv.NumError); !ok || e.Err == strconv.ErrRange {
			break
		}
	}

	if endptr != 0 {
		if digits > 0 {
			s += int32(prefix + digits)
		}
		store32((*m.memory)[uint32(endptr):], uint32(s))
	}
	return val
}
