-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
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
Remove calls to free() #123
Comments
Now, after transpile next C code: #include <stdlib.h>
int main() {
int * buf1, *buf2, *buf3;
buf1 = (int*) malloc(100*sizeof(int));
buf2 = (int*) calloc(100,sizeof(int));
buf3 = (int*) realloc(buf2, 500*sizeof(int));
free(buf1);
free(buf3);
return 0;
} we have errors: go run free.go
# command-line-arguments
./free.go:199:14: undefined: noarch.IntSliceToByteSlice
./free.go:200:14: undefined: noarch.IntSliceToByteSlice
./free.go:204:2: undefined: os
./free.go:206:14: undefined: os Go code: func main() {
__init()
var buf1 []int
var buf2 []int
var buf3 []int
buf1 = make([]int, 100*4/4)
buf2 = make([]int, 100*4/4)
buf3 = make([]int, 500*4/4)
noarch.Free(noarch.IntSliceToByteSlice(buf1))
noarch.Free(noarch.IntSliceToByteSlice(buf3))
return
} |
In according to http://www.cplusplus.com/reference/cstdlib/free/
Go code: _ = buf1 |
That's interesting. That would also work, but i'm thinking of completely removing the call to func main() {
__init()
var buf1 []int
var buf2 []int
var buf3 []int
buf1 = make([]int, 100*4/4)
buf2 = make([]int, 100*4/4)
buf3 = make([]int, 500*4/4)
return
} |
In your case, I see the problem - if you try for use
But if use I prepare the |
@Konstantin8105 I left some comments on the PR. |
free()
is not required in Go because it has automatic memory management. However, this relates to a larger issue of having code removed, rather than just transpiled directly.The text was updated successfully, but these errors were encountered: