From 50151b643fc800af1976644bbe01f4cc44866911 Mon Sep 17 00:00:00 2001 From: chai2010 Date: Fri, 5 Jan 2018 01:06:09 +0800 Subject: [PATCH] =?UTF-8?q?ch2-05:=20=E5=AE=8C=E5=96=84=E4=BE=8B=E5=AD=90,?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=E7=BC=93=E5=86=B2=E7=9A=84=E9=87=8A?= =?UTF-8?q?=E6=94=BE=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ch2-cgo/ch2-05-class.md | 2 ++ examples/ch2-05/class-cc2go/main.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ch2-cgo/ch2-05-class.md b/ch2-cgo/ch2-05-class.md index 6b94b0f..d2df707 100644 --- a/ch2-cgo/ch2-05-class.md +++ b/ch2-cgo/ch2-05-class.md @@ -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])))) } diff --git a/examples/ch2-05/class-cc2go/main.go b/examples/ch2-05/class-cc2go/main.go index 7d6d51e..d487d53 100644 --- a/examples/ch2-05/class-cc2go/main.go +++ b/examples/ch2-05/class-cc2go/main.go @@ -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])))) }