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
WIP: Schema #82
WIP: Schema #82
Conversation
This can happen if the first malloc for `buf.base` succeeds, but then the second malloc for req->data fails.
int64_t len = luaL_checkinteger(L, 2); | ||
int64_t offset = luaL_checkinteger(L, 3); | ||
uv_file file; | ||
int64_t len, offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint64_t?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just trying to match what libuv is expecting to go through minimal typecasts.
offset declared at https://github.com/joyent/libuv/blob/a4f88760be1838603fe2eae89a651066cc42eedd/include/uv.h#L1072
though I got size wrong, it should be unsigned int
from https://github.com/joyent/libuv/blob/a4f88760be1838603fe2eae89a651066cc42eedd/include/uv.h#L416
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k. that sounds reasonable.
The idea here is to go through all the user-facing functions and organize them into 3 sections.
1 - Declare all local variables at the top
2 - Check the arguments against a static schema
3 - Perform the action being aware of early exits and cleanup of resources.
There are quite a few memory leaks that are only triggered by various error cases. This refactor should fix most if not all of them.