// NewMemoryKeyValue returns a KeyValue implementation that's backed only
// by memory. It's mostly useful for tests and development.
10079
func NewMemoryKeyValue() KeyValue {
	db := memdb.New(comparer.DefaultComparer, 128)
	return &memKeys{db: db}
}
701067
func NewMemoryStore(collectNum int, expiration time.Duration) Store {
	s := new(memoryStore)
	s.digitsById = make(map[string][]byte)
	s.idByTime = list.New()
	s.collectNum = collectNum
	s.expiration = expiration
	return s
}
24099
func readKeyValue(size uint32, r io.Reader) ([]byte, []byte, error) {
	kvBytes := make([]byte, size)
	if _, err := r.Read(kvBytes); err != nil {
		return nil, nil, err
	}
	keyLen := encoding.Uint32(kvBytes[0:4])
	// we can grab the key from keyLen and the we know the value is stored
	// after the keyLen + 8 (4 byte size of key and value)
	return kvBytes[4 : keyLen+4], kvBytes[keyLen+8:], nil
}
1236188
func (confSrc *MemoryConfigurationSource) AddKeyValue(key string, value interface{}) error {
	if !confSrc.ChanStatus {
		<-confSrc.CallbackCheck
		confSrc.ChanStatus = true
	}

	event := new(core.Event)
	event.EventSource = confSrc.GetSourceName()
	event.Key = key
	event.Value = value

	confSrc.Lock()
	defer confSrc.Unlock()
	if _, ok := confSrc.Configurations[key]; !ok {
		event.EventType = core.Create
	} else {
		event.EventType = core.Update
	}

	confSrc.Configurations[key] = value

	if confSrc.callback != nil {
		confSrc.callback.OnEvent(event)
	}

	return nil
}
544844
func (t *Thread) WriteMemory(addr uintptr, data []byte) (int, error) {
	return 0, ErrWriteCore
}
1276752
func (b *BoltCreator) NewKeyValue(id string) (pinterface.IKeyValue, error) {
	return NewKeyValue(b.db, id)
}
367969
func NewKeyValuesStrings(key string, values ...string) KeyValues {
	iv := make([]interface{}, len(values))
	for i := 0; i < len(values); i++ {
		iv[i] = values[i]
	}
	return KeyValues{Key: key, Values: iv}
}
1277180
func NewMemoryIndex() *Index {
	ix, err := New(sorted.NewMemoryKeyValue())
	if err != nil {
		// Nothing to fail in memory, so worth panicing about
		// if we ever see something.
		panic(err)
	}
	return ix
}
127720
func parseKeyValue(body []byte) (map[string]string, error) {
	p := make(map[string]string)
	for _, b := range bytes.Split(body, []byte("\n")) {
		if len(b) == 0 {
			continue
		}
		parts := bytes.SplitN(b, []byte(":"), 2)
		if len(parts) != 2 {
			return nil, fmt.Errorf("invalid key-value line %q", b)
		}
		p[string(parts[0])] = string(parts[1])
	}
	return p, nil
}
1154875
func NewKeyValueMaybeWipe(cfg jsonconfig.Obj) (KeyValue, error) {
	kv, err := NewKeyValue(cfg)
	if err == nil {
		return kv, nil
	}
	if _, ok := err.(NeedWipeError); !ok {
		return nil, err
	}
	wiper, ok := kv.(Wiper)
	if !ok {
		return nil, fmt.Errorf("storage type %T needs wiping because %v. But it doesn't support sorted.Wiper", err, kv)
	}
	we := err
	if err := wiper.Wipe(); err != nil {
		return nil, fmt.Errorf("sorted key/value type %T needed wiping because %v. But could not wipe: %v", kv, we, err)
	}
	return kv, nil
}
560469
func NewInMemoryKeyStore() bccsp.KeyStore {
	eks := &inmemoryKeyStore{}
	eks.keys = make(map[string]bccsp.Key)
	return eks
}
1290461
func NewMemoryBackend(max int) *MemoryBackend {
	return &MemoryBackend{
		messages: make(chan *gomail.Message, max),
	}
}
246106
func NewMemoryPool() *MemoryPool {
	return &MemoryPool{
		entries: map[string]*token.PlainOutput{},
		history: map[string]*token.TokenTransaction{},
	}
}
1319210
func NewMemoryProfile(m string) (MemoryProfile, error) {
	mp := MemoryProfile(m)
	if err := mp.Validate(); err != nil {
		return MemoryProfile(""), err
	}
	return mp, nil
}
1186408
func newKeyValueFromJSONConfig(cfg jsonconfig.Obj) (sorted.KeyValue, error) {
	file := cfg.RequiredString("file")
	if err := cfg.Validate(); err != nil {
		return nil, err
	}
	opts := &kv.Options{}
	db, err := kvutil.Open(file, opts)
	if err != nil {
		return nil, err
	}
	is := &kvis{
		db:   db,
		opts: opts,
		path: file,
	}
	return is, nil
}
669534
func NewCredSshKeyFromMemory(username string, publicKey string, privateKey string, passphrase string) (int, Cred) {
	cred := Cred{}
	cusername := C.CString(username)
	defer C.free(unsafe.Pointer(cusername))
	cpublickey := C.CString(publicKey)
	defer C.free(unsafe.Pointer(cpublickey))
	cprivatekey := C.CString(privateKey)
	defer C.free(unsafe.Pointer(cprivatekey))
	cpassphrase := C.CString(passphrase)
	defer C.free(unsafe.Pointer(cpassphrase))
	ret := C.git_cred_ssh_key_memory_new(&cred.ptr, cusername, cpublickey, cprivatekey, cpassphrase)
	return int(ret), cred
}
2473
func keyValueInstruction(cmd string, m []KeyValue) (string, error) {
	s := []string{strings.ToUpper(cmd)}
	for _, kv := range m {
		// Marshal kv.Key and kv.Value as JSON strings to cover cases
		// like when the values contain spaces or special characters.
		k, err := json.Marshal(kv.Key)
		if err != nil {
			return "", err
		}
		v, err := json.Marshal(kv.Value)
		if err != nil {
			return "", err
		}
		s = append(s, fmt.Sprintf("%s=%s", k, v))
	}
	return strings.Join(s, " "), nil
}