Skip to content

Instantly share code, notes, and snippets.

@andydude
Created April 14, 2012 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andydude/2386182 to your computer and use it in GitHub Desktop.
Save andydude/2386182 to your computer and use it in GitHub Desktop.
// filename: cmd/foo/foo.go
package main
import simple "simple"
func main() {
d := simple.GetData()
simple.PutData(d)
}
*data=hello
data=0x42045000
data=0x442086fb8
*data=
#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);
}
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