Skip to content
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

Let user specify function to use for freeing foreign buffers #8465

Closed
Erik-S opened this issue Aug 12, 2013 · 2 comments
Closed

Let user specify function to use for freeing foreign buffers #8465

Erik-S opened this issue Aug 12, 2013 · 2 comments
Labels
E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot.

Comments

@Erik-S
Copy link

Erik-S commented Aug 12, 2013

Pull #8296 adds a type (CString) to wrap char pointers returned from C code into Rust strings. The Drop impl on CString function always calls libc::free(). This is not generally correct on Windows.

On Windows, each function or API specifies which free()-like function to use. Not using the correct function will cause problems.

Raymond Chen (at the Old New Thing blog) has more details on why Windows works this way: http://blogs.msdn.com/b/oldnewthing/archive/2006/09/15/755966.aspx

I don't know Rust well enough to say what the correct fix is. Maybe pass in a function pointer to the constructor that is called at drop? The pointer could replace the "owns_buffer" bool if we use an optional pointer.

@emberian
Copy link
Member

emberian commented Jan 6, 2014

Presumably allocator parameterization would solve this. But it's such a hairball to deal with.

@alexcrichton
Copy link
Member

This was resolved in #20507

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot.
Projects
None yet
Development

No branches or pull requests

3 participants