Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upuvwget sample is bad. #1364
Comments
bnoordhuis
added
the
doc
label
May 31, 2017
This comment has been minimized.
This comment has been minimized.
|
Pull requests welcome. We adopted the libuv book wholesale from its author, quirks and all. Libuv's internal style would be to use a container_of-like macro. |
This comment has been minimized.
This comment has been minimized.
|
Using the If we want that our private struct be released when the request (or handle) is released then using a "baton" would be better. Check here |
This comment has been minimized.
This comment has been minimized.
|
@kroggen As Ben pointed out, container_of is a cleaner approach. |
This comment has been minimized.
This comment has been minimized.
|
Yeah, I agree. I didn't write the opposite. I just wrote about batons, that can be used with container_of. |
bnoordhuis
added
good-first-contribution
help-wanted
labels
Jul 13, 2017
rayrase
referenced this issue
Oct 4, 2017
Open
replaced cast to curl_context_t with container_of #1586
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ryutei commentedMay 31, 2017
Hello.
Recently I read user-guide of libuv. I'm confused by External I/O with polling code. Here is the thing:
uvwget/main.c
OK, curl_context_t has uv_poll_t as head of member, this is why curl_perform function can get curl_context_t* from cast of (incompatible) uv_poll_t*. But I think this is anti-pattern of C language. It’s not ordinary way.
uv_poll_t is virtually subclass of uv_handle_t, so it has public member 'data'. External library should use 'data' to store own context, instead of misleading pointer cast of uv_poll_t*.