Created
April 14, 2012 17:43
-
-
Save andydude/2386182 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// filename: cmd/foo/foo.go | |
package main | |
import simple "simple" | |
func main() { | |
d := simple.GetData() | |
simple.PutData(d) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*data=hello | |
data=0x42045000 | |
data=0x442086fb8 | |
*data= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <runtime.h> | |
int8* | |
simple·GetData() { | |
int8 *data = runtime·malloc(6); | |
runtime·memmove(data, "hello", 6); | |
runtime·printf("*data=%s\n", data); | |
runtime·printf("data=%p\n", data); | |
return data; | |
} | |
void | |
simple·PutData(int8* data) { | |
runtime·printf("data=%p\n", data); | |
runtime·printf("*data=%s\n", data); | |
runtime·free(data); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package simple | |
func GetData() *byte | |
func PutData(b *byte) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment