diff options
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 d55a335..dbfffe0 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 { | |||
85 | 85 | ||
86 | // toAddrPointer converts an interface to a pointer that points to | 86 | // toAddrPointer converts an interface to a pointer that points to |
87 | // the interface data. | 87 | // the interface data. |
88 | func toAddrPointer(i *interface{}, isptr bool) pointer { | 88 | func toAddrPointer(i *interface{}, isptr, deref bool) (p pointer) { |
89 | // Super-tricky - read or get the address of data word of interface value. | 89 | // Super-tricky - read or get the address of data word of interface value. |
90 | if isptr { | 90 | if isptr { |
91 | // The interface is of pointer type, thus it is a direct interface. | 91 | // The interface is of pointer type, thus it is a direct interface. |
92 | // The data word is the pointer data itself. We take its address. | 92 | // The data word is the pointer data itself. We take its address. |
93 | return pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)} | 93 | p = pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)} |
94 | } else { | ||
95 | // The interface is not of pointer type. The data word is the pointer | ||
96 | // to the data. | ||
97 | p = pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} | ||
94 | } | 98 | } |
95 | // The interface is not of pointer type. The data word is the pointer | 99 | if deref { |
96 | // to the data. | 100 | p.p = *(*unsafe.Pointer)(p.p) |
97 | return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} | 101 | } |
102 | return p | ||
98 | } | 103 | } |
99 | 104 | ||
100 | // valToPointer converts v to a pointer. v must be of pointer type. | 105 | // valToPointer converts v to a pointer. v must be of pointer type. |