We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package main /* #include <ctype.h> #include <stdlib.h> char* str_to_lower(char* str) { char* p = str; if(str == NULL || str[0] == '\0') { return str; } for(; *p != '\0'; p++) { *p = tolower(*p); } return str; } */ import "C" import "unsafe" func str_to_lower(s string) string { cs1 := C.CString(s) defer C.free(unsafe.Pointer(cs1)) cs2 := C.str_to_lower(cs1) defer C.free(unsafe.Pointer(cs2)) return C.GoString(cs2) } func main() { println(str_to_lower("")) }
go version go version go1.4.1 windows/amd64
gcc --version gcc (tdm64-1) 4.9.2
The text was updated successfully, but these errors were encountered:
It shouldn't C.free the pointer returned from C.str_to_lower.
It's caused by double free error, and has nothing to do with Go.
Sorry, something went wrong.
No branches or pull requests
go version
go version go1.4.1 windows/amd64
gcc --version
gcc (tdm64-1) 4.9.2
The text was updated successfully, but these errors were encountered: