[golang]从golang中的Slice和strin…

type SliceHeader struct {
 
  
    Data uintptr
 
  
    Len  int
 
  
    Cap  int
 
  
}
 
  
type StringHeader struct {
 
  
    Data uintptr
 
  
    Len  int
 
  
}
以上数据结构来源于package reflect
有了以上数据结构 就可以将从C malloc得到的内存转换成Go slice和string使用
 
  
具体方法以后补充 如何将从C malloc到的unsafe.Pointer转换为Go内置数据结构
 
  
 
  
[1]http://blog.rqhut.net/article/[golang]数组、切片和字符串的内存结构
[2]http://my.oschina.net/lubia/blog/175154

猜你喜欢

转载自blog.csdn.net/vipally/article/details/40952811