Keep reference of interface value

This commit is contained in:
Masaaki Goshima 2020-09-17 21:48:39 +09:00
parent 024abcd29d
commit 66b8cb792a
1 changed files with 2 additions and 0 deletions

View File

@ -28,11 +28,13 @@ func mapassign(t *rtype, m unsafe.Pointer, key, val unsafe.Pointer)
func (d *mapDecoder) setKey(buf []byte, cursor int64, key interface{}) (int64, error) { func (d *mapDecoder) setKey(buf []byte, cursor int64, key interface{}) (int64, error) {
header := (*interfaceHeader)(unsafe.Pointer(&key)) header := (*interfaceHeader)(unsafe.Pointer(&key))
d.dummy = header
return d.keyDecoder.decode(buf, cursor, uintptr(header.ptr)) return d.keyDecoder.decode(buf, cursor, uintptr(header.ptr))
} }
func (d *mapDecoder) setValue(buf []byte, cursor int64, key interface{}) (int64, error) { func (d *mapDecoder) setValue(buf []byte, cursor int64, key interface{}) (int64, error) {
header := (*interfaceHeader)(unsafe.Pointer(&key)) header := (*interfaceHeader)(unsafe.Pointer(&key))
d.dummy = header
return d.valueDecoder.decode(buf, cursor, uintptr(header.ptr)) return d.valueDecoder.decode(buf, cursor, uintptr(header.ptr))
} }