forked from mirror/ledisdb
bugfix: BufGet must make if b is nil
This commit is contained in:
parent
66d2b3b8ba
commit
51a5dc9212
|
@ -345,7 +345,7 @@ func (db *DB) get(r []byte, ro *ReadOptions, key []byte) ([]byte, error) {
|
||||||
|
|
||||||
defer C.leveldb_get_free_ext(unsafe.Pointer(c))
|
defer C.leveldb_get_free_ext(unsafe.Pointer(c))
|
||||||
|
|
||||||
if int(C.int(vallen)) > len(r) {
|
if r == nil || int(C.int(vallen)) > len(r) {
|
||||||
return C.GoBytes(unsafe.Pointer(value), C.int(vallen)), nil
|
return C.GoBytes(unsafe.Pointer(value), C.int(vallen)), nil
|
||||||
} else {
|
} else {
|
||||||
b := slice(unsafe.Pointer(value), int(C.int(vallen)))
|
b := slice(unsafe.Pointer(value), int(C.int(vallen)))
|
||||||
|
|
|
@ -98,7 +98,7 @@ func (it *Iterator) BufKey(b []byte) []byte {
|
||||||
if k == nil {
|
if k == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if len(k) > len(b) {
|
if b == nil || len(k) > len(b) {
|
||||||
b = make([]byte, len(k))
|
b = make([]byte, len(k))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ func (it *Iterator) BufValue(b []byte) []byte {
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if len(v) > len(b) {
|
if b == nil || len(v) > len(b) {
|
||||||
b = make([]byte, len(v))
|
b = make([]byte, len(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,6 +208,14 @@ func (it *RangeLimitIterator) RawValue() []byte {
|
||||||
return it.it.RawValue()
|
return it.it.RawValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (it *RangeLimitIterator) BufKey(b []byte) []byte {
|
||||||
|
return it.it.BufKey(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (it *RangeLimitIterator) BufValue(b []byte) []byte {
|
||||||
|
return it.it.BufValue(b)
|
||||||
|
}
|
||||||
|
|
||||||
func (it *RangeLimitIterator) Valid() bool {
|
func (it *RangeLimitIterator) Valid() bool {
|
||||||
if it.l.Offset < 0 {
|
if it.l.Offset < 0 {
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue