summaryrefslogtreecommitdiff
path: root/src/pkg/unsafe
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-12-07 15:51:58 -0800
committerRuss Cox <rsc@golang.org>2009-12-07 15:51:58 -0800
commit3476dcd6cfad0a7e2ba31b33598289428fed1d79 (patch)
treefe649ba45f677c9db58b27dbfa5b4d556285cc6a /src/pkg/unsafe
parent1ce9abc3439aabd571100375149c304194016b35 (diff)
downloadgo-3476dcd6cfad0a7e2ba31b33598289428fed1d79.tar.gz
runtime: introduce unsafe.New and unsafe.NewArray
to provide functionality previously hacked in to reflect and gob. R=r http://codereview.appspot.com/165076
Diffstat (limited to 'src/pkg/unsafe')
-rw-r--r--src/pkg/unsafe/unsafe.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/pkg/unsafe/unsafe.go b/src/pkg/unsafe/unsafe.go
index d55aa2446..fc583fe95 100644
--- a/src/pkg/unsafe/unsafe.go
+++ b/src/pkg/unsafe/unsafe.go
@@ -43,5 +43,17 @@ func Typeof(i interface{}) (typ interface{})
func Reflect(i interface{}) (typ interface{}, addr uintptr)
// Unreflect inverts Reflect: Given a type and a pointer, it returns an empty interface value
-// with those contents.
+// with those contents. The typ is assumed to contain a pointer to a runtime type;
+// the type information in the interface{} is ignored, so that, for example, both
+// *reflect.StructType and *runtime.StructType can be passed for typ.
func Unreflect(typ interface{}, addr uintptr) (ret interface{})
+
+// New allocates and returns a pointer to memory for a new value of the given type.
+// The typ is assumed to hold a pointer to a runtime type.
+// Callers should use reflect.MakeZero instead of invoking unsafe.New directly.
+func New(typ interface{}) Pointer
+
+// NewArray allocates and returns a pointer to an array of n elements of the given type.
+// The typ is assumed to hold a pointer to a runtime type.
+// Callers should use reflect.MakeSlice instead of invoking unsafe.NewArray directly.
+func NewArray(typ interface{}, n int) Pointer