// MaxBytes, ignored if set to value >=, if request exceeds the specified limit, the reader will return error,
// by default buffer is not limited, negative values mean no limit
194259
func MaxBytes(m int64) optionSetter {
	return func(o *options) error {
		o.maxBytes = m
		return nil
	}
}
947461
func MaxAge(val uint) {
	if cors, ok := corsDefinition(); ok {
		cors.MaxAge = val
	}
}
1121181
func WrapBytes(b []byte, lim int) []byte {
	words := bytes.Split(bytes.Replace(bytes.TrimSpace(b), nl, sp, -1), sp)
	var lines [][]byte
	for _, line := range WrapWords(words, 1, lim, defaultPenalty) {
		lines = append(lines, bytes.Join(line, sp))
	}
	return bytes.Join(lines, nl)
}
1054043
func LimitByRequest(limiter *config.Limiter, r engine.Request) *echo.HTTPError {
	sliceKeys := BuildKeys(limiter, r)

	// Loop sliceKeys and check if one of them has error.
	for _, keys := range sliceKeys {
		httpError := LimitByKeys(limiter, keys)
		if httpError != nil {
			return httpError
		}
	}

	return nil
}
511170
func (nc *Conn) MaxPayload() int64 {
	nc.mu.RLock()
	defer nc.mu.RUnlock()
	return nc.info.MaxPayload
}
636973
func MaxUint64N(v ...uint64) uint64 {
	switch len(v) {
	case 0:
		return 0
	case 1:
		return v[0]
	case 2:
		return MaxUint64(v[0], v[1])
	default:
		l := len(v) / 2
		return MaxUint64N(MaxUint64N(v[:l]...), MaxUint64N(v[l:]...))
	}
}
562164
func (s *SecureCookie) MaxLength(value int) *SecureCookie {
	s.maxLength = value
	return s
}
1030464
func SequenceLimit(size int64, readers ...io.Reader) io.Reader {
	return io.LimitReader(
		io.MultiReader(readers...),
		size)
}
1126752
func NewLimitedBytes(capacity int, maxSize int) *LimitedBytes {
	return &LimitedBytes{
		pool:    make(chan []byte, capacity),
		maxSize: maxSize,
	}
}
681351
func (st *Store) MaxLength(l int) {
	for _, c := range st.Codecs {
		if codec, ok := c.(*securecookie.SecureCookie); ok {
			codec.MaxLength(l)
		}
	}
}
620505
func requestLimitEnforcedValues(requestQuantity, limitQuantity, enforcedQuantity resource.Quantity) (request, limit, enforced int64) {
	request = requestQuantity.Value()
	limit = limitQuantity.Value()
	enforced = enforcedQuantity.Value()
	// do a more precise comparison if possible (if the value won't overflow)
	if request <= resource.MaxMilliValue && limit <= resource.MaxMilliValue && enforced <= resource.MaxMilliValue {
		request = requestQuantity.MilliValue()
		limit = limitQuantity.MilliValue()
		enforced = enforcedQuantity.MilliValue()
	}
	return
}
92327
func ParseMaxAge(header string) int64 {
	if header == "" {
		return -1
	}
	m := maxAgeExp.FindStringSubmatch(header)
	if len(m) == 2 {
		if v, err := strconv.Atoi(m[1]); err == nil {
			return int64(v)
		}
	}
	return -1
}
530872
func (r *RateLimiter) Limit(dataSize int) time.Duration {
	r.lock.Lock()
	defer r.lock.Unlock()
	//  update time
	var duration time.Duration = time.Duration(0)
	if r.bandwidth == 0 {
		return duration
	}
	current := time.Now()
	elapsedTime := current.Sub(r.lastUpdate)
	r.lastUpdate = current

	allowance := r.allowance + float64(elapsedTime)*r.bandwidth
	//  allowance can't exceed bandwidth
	if allowance > r.maxAllowance {
		allowance = r.maxAllowance
	}

	allowance -= float64(dataSize)
	if allowance < 0 {
		//  sleep until allowance is back to 0
		duration = time.Duration(-allowance / r.bandwidth)
		//  rate limiting was applied, record stats
		r.count++
		r.duration += duration
	}

	r.allowance = allowance
	return duration
}
443095
func (s *FilesystemStore) MaxAge(age int) {
	s.Options.MaxAge = age

	// Set the maxAge for each securecookie instance.
	for _, codec := range s.Codecs {
		if sc, ok := codec.(*securecookie.SecureCookie); ok {
			sc.MaxAge(age)
		}
	}
}
1023498
func (s *stream) readBytes(n uint32) ([]byte, error) {
	if n > s.size {
		s.buf = make([]byte, n)
		s.size = n
	}

	if _, err := io.ReadFull(s.Reader, s.buf[:n]); err != nil {
		return nil, err
	}

	return s.buf[:n], nil
}
913606
func (s *Stream) ReadSysExBytes(max int) ([]byte, error) {
	if max > maxEventBufferSize {
		return nil, ErrMaxBuffer
	}
	if max < minEventBufferSize {
		return nil, ErrMinBuffer
	}
	buffer := make([]C.PmEvent, max)
	numEvents := C.Pm_Read(unsafe.Pointer(s.pmStream), &buffer[0], C.int32_t(max))
	if numEvents < 0 {
		return nil, convertToError(C.PmError(numEvents))
	}
	msg := make([]byte, 4*numEvents)
	for i := 0; i < int(numEvents); i++ {
		msg[4*i+0] = byte(buffer[i].message & 0xFF)
		msg[4*i+1] = byte((buffer[i].message >> 8) & 0xFF)
		msg[4*i+2] = byte((buffer[i].message >> 16) & 0xFF)
		msg[4*i+3] = byte((buffer[i].message >> 24) & 0xFF)
	}
	return msg, nil
}
601061
func getMaxLimits(limit *corev1.LimitRange, current corev1.ResourceList) corev1.ResourceList {
	res := current

	for _, item := range limit.Spec.Limits {
		if item.Type != imagev1.LimitTypeImageStream {
			continue
		}
		for _, resource := range []corev1.ResourceName{imagev1.ResourceImageStreamImages, imagev1.ResourceImageStreamTags} {
			if max, ok := item.Max[resource]; ok {
				if oldMax, exists := res[resource]; !exists || oldMax.Cmp(max) > 0 {
					if res == nil {
						res = make(corev1.ResourceList)
					}
					res[resource] = max
				}
			}
		}
	}

	return res
}