...
1
2
3
4
5 package main
6
7
8
9
10
11
12
13
23 import "C"
24
25 import (
26 "fmt"
27 )
28
29 const (
30 maxStack = 1024
31 )
32
33 func init() {
34 register("CgoEscapeWithMultiplePointers", CgoEscapeWithMultiplePointers)
35 }
36
37 func CgoEscapeWithMultiplePointers() {
38 stackGrow(maxStack)
39 fmt.Println("OK")
40 }
41
42
43 func testCWithMultiplePointers() {
44 var a C.int = 1
45 var b C.int = 2
46 var c C.int = 3
47 v := C.add_from_multiple_pointers(&a, &b, &c)
48 if v != 9 || a != 2 || b != 3 || c != 4 {
49 fmt.Printf("%d + %d + %d != %d\n", a, b, c, v)
50 }
51 }
52
53 func stackGrow(n int) {
54 if n == 0 {
55 return
56 }
57 testCWithMultiplePointers()
58 stackGrow(n - 1)
59 }
60
View as plain text