aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/print.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2015-10-20 00:35:12 -0700
committerMatthew Dempsky <mdempsky@google.com>2015-10-20 23:13:27 +0000
commitd4a7ea1b71523115f9baead2d0f98fd8cf517577 (patch)
treee2c06b78fd0c18d670c95a2b0163108046581fd0 /src/runtime/print.go
parentef986fa3fc9b8035151e10658de66873bb25bba5 (diff)
downloadgo-d4a7ea1b71523115f9baead2d0f98fd8cf517577.tar.gz
go-d4a7ea1b71523115f9baead2d0f98fd8cf517577.zip
runtime: add stringStructOf helper function
Instead of open-coding conversions from *string to unsafe.Pointer then to *stringStruct, add a helper function to add some type safety. Bonus: This caught two **string values being converted to *stringStruct in heapdump.go. While here, get rid of the redundant _string type, but add in a stringStructDWARF type used for generating DWARF debug info. Change-Id: I8882f8cca66ac45190270f82019a5d85db023bd2 Reviewed-on: https://go-review.googlesource.com/16131 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/print.go')
-rw-r--r--src/runtime/print.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/runtime/print.go b/src/runtime/print.go
index 6eff38168d..841e684eca 100644
--- a/src/runtime/print.go
+++ b/src/runtime/print.go
@@ -12,8 +12,8 @@ type hex uint64
func bytes(s string) (ret []byte) {
rp := (*slice)(unsafe.Pointer(&ret))
- sp := (*_string)(noescape(unsafe.Pointer(&s)))
- rp.array = unsafe.Pointer(sp.str)
+ sp := stringStructOf(&s)
+ rp.array = sp.str
rp.len = sp.len
rp.cap = sp.len
return