diff options
author | 2019-09-05 21:39:32 -0700 | |
---|---|---|
committer | 2019-09-05 21:53:12 -0700 | |
commit | b94160df725a52af53f113bf27de7a7b8723174c (patch) | |
tree | 9e86b227d4683f26da9b393410df1bedc2e95074 /vendor/github.com/golang/protobuf/proto/pointer_unsafe.go | |
parent | 456ebaf423ce2122bf8faa36da464c5d90361204 (diff) | |
download | v2-b94160df725a52af53f113bf27de7a7b8723174c.tar.gz v2-b94160df725a52af53f113bf27de7a7b8723174c.tar.zst v2-b94160df725a52af53f113bf27de7a7b8723174c.zip |
Update dependencies
Diffstat (limited to 'vendor/github.com/golang/protobuf/proto/pointer_unsafe.go')
-rw-r--r-- | vendor/github.com/golang/protobuf/proto/pointer_unsafe.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go index d55a335d..dbfffe07 100644 --- a/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go +++ b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go @@ -85,16 +85,21 @@ func toPointer(i *Message) pointer { // toAddrPointer converts an interface to a pointer that points to // the interface data. -func toAddrPointer(i *interface{}, isptr bool) pointer { +func toAddrPointer(i *interface{}, isptr, deref bool) (p pointer) { // Super-tricky - read or get the address of data word of interface value. if isptr { // The interface is of pointer type, thus it is a direct interface. // The data word is the pointer data itself. We take its address. - return pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)} + p = pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)} + } else { + // The interface is not of pointer type. The data word is the pointer + // to the data. + p = pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} } - // The interface is not of pointer type. The data word is the pointer - // to the data. - return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} + if deref { + p.p = *(*unsafe.Pointer)(p.p) + } + return p } // valToPointer converts v to a pointer. v must be of pointer type. |