Skip to content

io: free Windows operation data with _aligned_free() #493

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

Merged
merged 1 commit into from
Jun 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2483,8 +2483,14 @@ _dispatch_operation_deliver_data(dispatch_operation_t op,
if (op->direction == DOP_DIR_READ) {
if (op->buf_len) {
void *buf = op->buf;
#if defined(_WIN32)
// buf is allocated with _aligned_malloc()
data = dispatch_data_create(buf, op->buf_len, NULL,
^{ _aligned_free(buf); });
#else
data = dispatch_data_create(buf, op->buf_len, NULL,
DISPATCH_DATA_DESTRUCTOR_FREE);
#endif
op->buf = NULL;
op->buf_len = 0;
dispatch_data_t d = dispatch_data_create_concat(op->data, data);
Expand Down