]> Cypherpunks repositories - gostls13.git/commitdiff
misc/cgo/testcarchive: avoid bad pointer passing
authorDavid Crawshaw <crawshaw@golang.org>
Mon, 13 Apr 2015 18:54:36 +0000 (14:54 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Mon, 13 Apr 2015 19:00:52 +0000 (19:00 +0000)
Change-Id: Ifbcc0eb24834f2f7d3b160d1dc911209723d9797
Reviewed-on: https://go-review.googlesource.com/8863
Reviewed-by: Ian Lance Taylor <iant@golang.org>
misc/cgo/testcarchive/main.c
misc/cgo/testcarchive/src/p/p.go

index 404e8f8e363a47ad0a63128ca968e166c24efbeb..3ce12682b83a213a101f3515083fb40201cd237a 100644 (file)
@@ -4,15 +4,13 @@
 
 #include <stdint.h>
 #include <stdio.h>
-#include <string.h>
 
-typedef struct { char *p; intmax_t n; } GoString;
 extern signed char DidInitRun();
 extern signed char DidMainRun();
-extern GoString FromPkg();
+extern int32_t FromPkg();
 
 int main(void) {
-       GoString res;
+       int32_t res;
 
        if (DidMainRun()) {
                fprintf(stderr, "ERROR: buildmode=c-archive should not run main\n");
@@ -25,8 +23,8 @@ int main(void) {
        }
 
        res = FromPkg();
-       if (strcmp(res.p, "str")) {
-               fprintf(stderr, "ERROR: FromPkg()='%s', want 'str'\n", res.p);
+       if (res != 1024) {
+               fprintf(stderr, "ERROR: FromPkg()=%d, want 1024\n", res);
                return 2;
        }
 
index 50275227a56dad118a57bc399337a382a774f07f..82b445c12109cb3a01f3ec59a2534d5d97768a3e 100644 (file)
@@ -7,4 +7,4 @@ package p
 import "C"
 
 //export FromPkg
-func FromPkg() string { return "str" }
+func FromPkg() int32 { return 1024 }