// makeSlice allocates a slice of size n. If the allocation fails, it panics
// with ErrTooLarge.
339822
func makeSlice(n int) (b []byte, err error) {
	// If the make fails, give a known error.
	defer func() {
		if recover() != nil {
			b = nil
			err = ErrTooLarge
			return
		}
	}()
	b = make([]byte, n)
	return
}
1186650
func ExpandSlice(slice string) (string, error) {
	suffix := ".slice"
	// Name has to end with ".slice", but can't be just ".slice".
	if len(slice) < len(suffix) || !strings.HasSuffix(slice, suffix) {
		return "", fmt.Errorf("invalid slice name: %s", slice)
	}

	// Path-separators are not allowed.
	if strings.Contains(slice, "/") {
		return "", fmt.Errorf("invalid slice name: %s", slice)
	}

	var path, prefix string
	sliceName := strings.TrimSuffix(slice, suffix)
	// if input was -.slice, we should just return root now
	if sliceName == "-" {
		return "/", nil
	}
	for _, component := range strings.Split(sliceName, "-") {
		// test--a.slice isn't permitted, nor is -test.slice.
		if component == "" {
			return "", fmt.Errorf("invalid slice name: %s", slice)
		}

		// Append the component to the path and to the prefix.
		path += "/" + prefix + component + suffix
		prefix += component + "-"
	}
	return path, nil
}
628079
func (c *MemoryStore) SetSlice(key string, value []interface{}) error {
	c.cache.Set(key, value, c.expiration)
	return nil
}
1075950
func (i *Iter) returnSlice(a, b int) []byte {
	if i.rb.src.bytes == nil {
		return i.buf[:copy(i.buf[:], i.rb.src.str[a:b])]
	}
	return i.rb.src.bytes[a:b]
}
469732
func mustArrayToByteSlice(value reflect.Value) reflect.Value {
	slice := reflect.MakeSlice(reflect.TypeOf([]byte{}), value.Len(), value.Len())
	reflect.Copy(slice, value)
	return slice
}
1311750
func getByteSlice(size int) []byte {
	fromPool := bsPool.Get()
	if fromPool == nil {
		return make([]byte, size)
	}
	bs := fromPool.([]byte)
	if cap(bs) < size {
		bs = make([]byte, size)
	}
	return bs[0:size]
}
198176
func (db *DB) GetSlice(key []byte) (store.Slice, error) {
	if err := checkKeySize(key); err != nil {
		return nil, err
	}

	key = db.encodeKVKey(key)

	return db.bucket.GetSlice(key)
}
824685
func (st StackTrace) formatSlice(s fmt.State, verb rune) {
	io.WriteString(s, "[")
	for i, f := range st {
		if i > 0 {
			io.WriteString(s, " ")
		}
		f.Format(s, verb)
	}
	io.WriteString(s, "]")
}
997467
func sanitizeSlice(names []string) []string {
	sanitized := []string{}
	for _, n := range names {
		sanitized = append(sanitized, sanitize(n))
	}
	return sanitized
}
1246389
func StringSlice(value []string, name, usage string) *[]string {
	p := new([]string)
	flag.Var(NewStringSlice(value, p), name, usage)
	return p
}
199531
func StringToSlice(data string) *Slice {
	return NewSlice(C.CString(data), C.size_t(len(data)))
}
979554
func NewSlice(data *C.char, size C.size_t) *Slice {
	return &Slice{data, size, false}
}
618451
func IntInSlice(a int, list []int) bool {
	for _, b := range list {
		if b == a {
			return true
		}
	}
	return false
}
857516
func encodeByteSlice(v reflect.Value) (interface{}, error) {
	var b []byte
	if !v.IsNil() {
		b = v.Bytes()
	}

	dst := make([]byte, base64.StdEncoding.EncodedLen(len(b)))
	base64.StdEncoding.Encode(dst, b)

	return map[string]interface{}{
		"$reql_type$": "BINARY",
		"data":        string(dst),
	}, nil
}
240222
func (k *Client) SendSlice(content []interface{}) *Client {
	k.SliceData = append(k.SliceData, content...)
	return k
}
747759
func CopyByteSlice(in []byte) []byte {
	if in == nil {
		return nil
	}
	out := make([]byte, len(in))
	copy(out, in)
	return out
}
24481
func (pool *ByteBlockPool) NewSlice(size int) int {
	if pool.ByteUpto > BYTE_BLOCK_SIZE-size {
		pool.NextBuffer()
	}
	upto := pool.ByteUpto
	pool.ByteUpto += size
	pool.Buffer[pool.ByteUpto-1] = 16
	return upto
}