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

Clarify ownership responsibilities in the C API docs #3296

Merged
merged 1 commit into from
Aug 31, 2023

Conversation

nnethercote
Copy link
Contributor

When using the C API for the first time I found the documentation missing some important details.

@nnethercote
Copy link
Contributor Author

Hi, this is my first PR for hyper, I may be doing some things incorrectly. Please read the commits one at a time. Thanks!

@seanmonstar
Copy link
Member

Thanks so much for the documentation improvements, these are great! ❤️

It looks like the generate header file has some changes the CI doesn't like. Is it because the cbindgen you have is an older version? Or it could be something we need to fix in CI...

@nnethercote nnethercote force-pushed the docs-clarify-ownership branch from a857a26 to e76f044 Compare August 30, 2023 22:58
Curl had two memory leaks in its usage of the hyper C API. I fixed these
in curl/curl#11729. While fixing these, as a
hyper newbie I found a lack of clarity in the docs about where the
responsibilities lie for allocating and deallocating things. I had to
repeatedly look at the `Box::into_raw`/`Box::from_raw` calls in the C
API code to properly understand things.

This commit extends the docs.
- For all functions that allocate things, make it clear which functions
  can be used to subsequently deallocate.
- For all functions that free things, make it clear if there are (or
  aren't) other functions that may have otherwise consumed the thing,
  thus removing the need for explicit freeing.
- Clarify some functions that consume things.

This is the documentation I wished was present when I was fixing the
leaks in curl.
@nnethercote nnethercote force-pushed the docs-clarify-ownership branch from e76f044 to 27246a9 Compare August 30, 2023 22:59
@nnethercote
Copy link
Contributor Author

I had cbindgen 0.12.0 installed, and CI uses 0.25.0! I upgraded, which should fix the problem.

@seanmonstar seanmonstar merged commit 82b7fa5 into hyperium:master Aug 31, 2023
@nnethercote nnethercote deleted the docs-clarify-ownership branch August 31, 2023 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants