1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-24 04:22:22 +00:00

ch2-05: 完善例子, 增加缓冲的释放工作

This commit is contained in:
chai2010 2018-01-05 01:06:09 +08:00
parent c6bc5a45a3
commit 50151b643f
2 changed files with 4 additions and 0 deletions

View File

@ -199,6 +199,8 @@ import "unsafe"
func main() {
buf := NewMyBuffer(1024)
defer buf.Delete()
copy(buf.Data(), []byte("hello\x00"))
C.puts((*C.char)(unsafe.Pointer(&(buf.Data()[0]))))
}

View File

@ -6,6 +6,8 @@ import "unsafe"
func main() {
buf := NewMyBuffer(1024)
defer buf.Delete()
copy(buf.Data(), []byte("hello\x00"))
C.puts((*C.char)(unsafe.Pointer(&(buf.Data()[0]))))
}