An array is a vector of values in memory. A slice is a small struct that describes an array stored elsewhere in memory.
Ian
If the words following p were not see, you'd have some fun memory corruption bugs to chase down.
// slice
struct {
elements unsafe.Pointer
len int // number of elements
cap int // capacity
}
If happens that the len and cap fields are both 0 for your unsafe slice.
As your using the unsafe package your doing things which are not considered safe by the lanaguge so only imprecise interpretations are possible. My interpretation is, assuming that next words after p in memory are zeroed the you have effectively a slice that points to a backing array at *p, and a length and capacity of zero.
If the words following p were not see, you'd have some fun memory corruption bugs to chase down.
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/tTmhJZTz3no/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.